I'm trying to make a callback that updates if it's been more than a second since the last report. It looks something like this
def main_func()
...
start_time = time.time()
def callback():
current_time = time.time()
if current_time - start_time > 1.0:
print 'working'
start_time = time.time()
work_function(args, callback)
Since start_time
is local the global
keyword won't work inside callback
. Is there a Python paradigm that can handle adding state to local functions?