I need to print the value of a variable every second or couple of seconds, while "at the same time" this variable is being modified. So I would be modifying this variable in my main function and I want something to print its value every second. Something like:
'''This is my main program'''
for i in range(very large number):
'''do something which modifies the value of 'var' '''
And somewhere else in the code:
'''Every second'''
print var
I took a look at this but I'm not sure if it's what I'm looking for, or how I should use it.
What I need is reaaaly simple, there are no other threads, and I don't care about syncing anything, or when in the main function the value is printed.