help understanding time.sleep() behavior

Andy Fox foxes at theriver.com
Fri Mar 10 18:28:50 EST 2000


Hi,

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

Any help is appreciated.

Andy



More information about the Python-list mailing list