help understanding time.sleep() behavior

Andy Fox foxes at theriver.com
Fri Mar 10 20:21:20 EST 2000


Thanks for the information, Gordon.  You are exactly right (but you knew
that already...).

Thanks again,
Andy

Gordon McMillan wrote:
> 
> Andy Fox wrote:
> >
> > I would like my program to pause for a second within a loop, but instead
> > it pauses for n seconds, where n is the number of iterations through the
> > loop, then executes the other statements.
> >
> > I'm running PythonWin on an NT machine.
> >
> > Here's the (embarassingly simple) code:
> >
> > >>> import time
> > >>> for x in range (5)
> > ...   print x
> > ...   time.sleep(1)
> > ...                    <-- pauses here for five seconds
> > 0                      <-- then prints the values quickly
> > 1
> > 2
> > 3
> > 4
> 
> Your program does exactly what you think it does. Pythonwin
> just buffers output in a non-smooth manner. Run it under
> python.exe instead and you'll see.
> 
> - Gordon



More information about the Python-list mailing list