Ask Your Question

Revision history [back]

Here's something I stumbled accross; it doesn't solve the carriage return problem, but does give a single line printed incrementally, so might work for you. The essential ingredient is sys.stdout.flush():

import sys
print "working:",
sys.stdout.flush()
for i in range(10):
    sleep(.5)
    print i,
    sys.stdout.flush()
print ''
sleep(1)
print "done!"

working: 0 1 2 3 4 5 6 7 8 9 
done!