Problems with sys.stout.flush()
Joel Ross
joelc at cognyx.com
Sun May 24 06:43:56 EDT 2009
AK wrote:
> import time, sys
>
> print "ONE",
> sys.stdout.flush()
> time.sleep(0.5)
> print "\rTWO",
> sys.stdout.flush()
> time.sleep(0.5)
>
Running the command above prints out
ONE
TWO
but running
for i in range(10):
print "ONE",
time.sleep(0.2)
prints out
ONE ONE ONE ONE ONE ONE ONE ONE ONE ONE
like Hendrik mentioned adding comma to the end prints out on one line.
But my problem problem wasn't printing on one line it was mathematical
each time I printed on one line it was appending the print before. Which
is all the above command does anyway. I had to apply some maths to solve
the issue I was having which was printing out a progress bar. I Got it
working though.
jross
More information about the Python-list
mailing list