On 6/23/2010 6:51 AM Steven D'Aprano said...
# untested
def call_again(n, func, *args):
     """call func(*args) every n seconds until ctrl-D"""
     import time
     try:
         while 1:
             start = time.time()
             func(*args)
             time.sleep(n - (time.time()-start))

Watch out for this -- you may want to do

  time.sleep(n - max(0,(time.time()-start)))

to avoid passing sleep a negative number which causes the big sleep...

Emile

_______________________________________________
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor

Reply via email to