sys.stdout is not flushed

Cousin Stanley cousinstanley at gmail.com
Tue Nov 24 03:32:50 CET 2009


>> ....
>> You misunderstand what "flush" means. It is not about 
>> clearing the screen, or the line.
>>
>> Try printing
>>
>>    stdout.write('\r-->%d')
>>
>> Diez
>
>
> But there is still a problem. When you use control character '\r', 
> you actually move to the head of the current buffer line and 
> overwrite it.
>
> So if I use this way:
> for i in range(100, 0,-1)
>
> The tail of the buffer is not overwrote.
> ....

  The following version works ok for me
  using python2.5 under debian linux ....

import sys
import time

print

for n in range( 11 ) :
    sys.stdout.write( '\r    Working ----> %d ' % n )
    sys.stdout.flush()
    time.sleep( 1 )

else :
    print "\n"
    print "    That's all, folks !"
    print "    Adios ........... "


-- 
Stanley C. Kitching
Human Being
Phoenix, Arizona




More information about the Python-list mailing list