I want to know about timer in Python.
Suppose i have a code snippet something like:
def abc()
print 'Hi'
print 'Hello'
print 'Hai'
And i want to print it every 1 second. Max three times;ie; 1st second i need to check the printf, 2nd second I need to check as well in 3rd second.
In my actual code variables value will be updated. I need to capture at what second all the variables are getting updated.
Can anybody tell me how to do this.
time.sleep
is fine in this case but what if theabc()
function takes half a second to execute? Or 5 minutes? In this case you should use aTimer
object.Use
time.sleep
.You should look into
time.sleep()
. For example:That will print your lines 5 times with a 3 second delay between.