Paul Rubin wrote: > John Salerno <[EMAIL PROTECTED]> writes: > >>>for x in range(minutes,0,-1): >>> sleep(60.0) >>> print minutes, 'minutes remaining' >>> >> >>Nice! Cross off another line! I feel like Hemingway. :) > > > 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 -- Steve Holden +44 150 684 7255 +1 800 494 3119 Holden Web LLC/Ltd www.holdenweb.com Love me, love my blog holdenweb.blogspot.com -- http://mail.python.org/mailman/listinfo/python-list