Print formatting - same line printing?

Michael Hudson mwh21 at cam.ac.uk
Sun Jun 4 12:29:27 EDT 2000


"Bablos" <angband at blueyonder.co.uk> writes:

> Hi There...
> 
> Now that I've got my FTP client doing some basic stuff, I now have a
> progress report which looks something like the following;
> 
> uploaded X bytes
> uploaded Y bytes
> uploaded Z bytes
> 
> Is there a way that I can get Python to print this all on the same
> line, so that it looks as if the line is being updated constantly, as
> opposed to having a ridiculously long list of 'uploaded...' lines?

Maybe 

print "uploaded %s bytes"%(bytecount,),

?  If you wat to replace the line you just wrote with a new line,
you're into escape code territory.  This sort of works on an xterm:

>>> for i in range(10):
...  print "uploaded %s bytes\033[A"%i 
...  time.sleep(1)
... 

but I think you probably want to look at curses to do this sensibly.

Cheers,
M.

-- 
  [Perl] combines all the  worst aspects of C and Lisp:  a billion
  different sublanguages in one monolithic executable. It combines 
  the power of C with the readability of PostScript.
                                                     -- Jamie Zawinski



More information about the Python-list mailing list