Print formatting - same line printing?

Remco Gerlich scarblac-spamtrap at pino.selwerd.nl
Sun Jun 4 07:16:47 EDT 2000


Bablos wrote in comp.lang.python:
> 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?
> 
> Hope someone can help.

Print, sys.stdout.write and so on all just push bytes into stdout. Any
tricks you could use to do this are very platform dependent. However, maybe
printing a lot of ^Hs to clear a line will work; see what

for i in range(10000):
   print i,
   print "\x008"*8,
   
does.

Nice to see people from the Angband world here, btw :-)

-- 
Remco Gerlich,  scarblac at pino.selwerd.nl
Hi! I'm a .sig virus! Join the fun and copy me into yours!



More information about the Python-list mailing list