Hi Frank,

 > how can I break a loop after a certain amount of time has passed?
 >


If the loop actually does something, I've used time.time() in the past:

start_time = time.time()
timeout = 60 #seconds


while True:
     do_something()
     if time.time() - start_time >= timeout:
         break

time.time() just keeps increasing as it reports the system's clock (in 
UNIX epoch time, just increasing seconds)

Hope that helps,

Hugo
_______________________________________________
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor

Reply via email to