# run infinitly
while(True):
done = False;
while(not done):
#Do Stuff
#Main Program
#stopping condition of inner while loop
if datetime.datetime.n
Rather than thrashing around constantly checking if it's 10 past the top of the hour, just do some math and sleep appropriately. Time is generally deterministic.
import datetime
import time
def seconds_till_10past():
now = datetime.datetime.now()
delta = now.replace(minute=10, second=0) - now
return delta.seconds % 3600
while True:
time.sleep(seconds_till_10past())
print "Do something at 10 past the hour."
Also, don't parenthesize arguments to statements (e.g. while(True)
), it's bad form.