sys.stdout is not flushed

Jankins andyjian430074 at gmail.com
Tue Nov 24 00:09:36 EST 2009


On Nov 23, 8:32 pm, Cousin Stanley <cousinstan... at gmail.com> wrote:
> >> ....
> >> 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

Thanks. It works. Put some space at the end of the output string.



More information about the Python-list mailing list