S
Steve Holden
Paul said:Besides the bug mentioned, I don't think you should really do it that
way, since sleep(60.0) might not sleep for exactly 60 sec (it could be
longer or shorter). Preferable is something like (untested):
now = time.time()
sleep_until = now + 60*minutes
while now < sleep_until:
print int((now - sleep_until)/60), 'minutes remaining'
sleep (60)
now = time.time()
You might actually want to stop sleeping a little bit early (say if
you wake up 5 seconds before sleep_until), or round the message to the
nearest number of minutes, etc.
You might also want to synchronize to a caesium clock, but the guy is
timing his laundry, for Pete's sake! Can we agree your approach, while
theoretically sound, might be a little over-complicated for a first
application?
regards
Steve