Problems with sys.stout.flush()

AK where at anywhere.com
Sun May 24 01:36:48 EDT 2009


Joel Ross wrote:
> Rhodri James wrote:
>> On Sat, 23 May 2009 18:19:11 +0100, Joel Ross <joelc at cognyx.com> wrote:
>>
>>> Now I can move onto next one.
>>
>> Except that you still have the interesting issue that your environment
>> isn't responding to '\r' correctly, which worries me rather.  Or did
>> you never test that?
>>
> Yeah I gave the "\r" a go and it kept printing out on a new line I will 
> look into it.
> 
> Thanks for the heads up

What happens when you run this little program:

import time, sys

print "ONE",
sys.stdout.flush()
time.sleep(0.5)
print "\rTWO",
sys.stdout.flush()
time.sleep(0.5)


The idea is that it should print ONE, flush it, sleep .5 sec so 
that you can see 'ONE', then return to start of line, print TWO, 
flush it so you can read it, and sleep another 0.5 sec.

NOTE comma after print statement.

Does that work for you?

-ak



More information about the Python-list mailing list