[Tutor] Timer?
D-Man
dsh8290@rit.edu
Fri, 30 Mar 2001 10:21:31 -0500
On Thu, Mar 29, 2001 at 08:17:58PM -0800, Britt Green wrote:
| I was wondering how to make a timer in Python. Say every ten seconds, I want
| Python to print out a string of text. How might I do this?
|
| Britt
import time
while 1 :
time.sleep( 10 ) # sleep (wait) for 10 seconds
print "Hello"
Various state, such as keeping track of how many iterations, etc, can
be added to this. If you want the program to continue to work (ie if
you have a gui) while this is printing 'hello' every ten seconds it
will need to be moved to a separate thread.
HTH,
-D