[Tutor] time.sleep

Deirdre Saoirse deirdre@deirdre.net
Wed, 22 Nov 2000 12:39:47 -0800 (PST)

On Wed, 22 Nov 2000, Remco Gerlich wrote:

> Hmm, this doesn't happen when I try it. But then, I don't know about
> your platform, how exactly you try it, etc. The output is probably
> buffered; it's still in the buffer when the program sleeps, you only
> see the print when the buffer is flushed later.

Yes, I also get the expected results. I've noticed that the result is held
in a buffer if the print line ends in a comma, but I've not seen it if it

> Two options that come to mind:
> - Flush stdout before the sleep with sys.stdout.flush()
> - Start Python with the -u option to disable all buffering on stdin, stdout
>   and stderr

Good workarounds.

_Deirdre      *      http://www.sfknit.org      *      http://www.deirdre.net
"Our society has not yet gone so far as to place blind faith in machines. In 
almost all endeavors, humans routinely correct the errors of machines."
                                                     - Florida Supreme Court