[Tutor] Sleeping it out
alan.gauld at btinternet.com
Sun Dec 9 01:37:09 CET 2007
"Ricardo Aráoz" <ricaraoz at gmail.com> wrote
> import time
> L = [i for i in xrange(20)]
> for n, i in enumerate(L) :
> if n%3 == 0 and n > 0 :
> print 'waiting 3 seconds'
> print i
> I'm using Py 2.51 and PyAlaMode. It works ok but instead of printing
> groups of three, it will go through the program but the printing
> appear all at once at the end of the loop. Is there any way to flush
Interestingly, it works perfectly at the command prompt but in
Pythonwin I get a similar but slightly different result to PyAlaMode.
the digits printed in groups but then I wait 3 seconds before the
message gets printed!
I assume this is due to how the various IDEs intercept stdout and
it on the GUI, but interesting that the results are different and both
More information about the Tutor