\r functionality

Duncan Booth duncan.booth at invalid.invalid
Tue May 17 07:52:05 EDT 2005


Jake wrote:

> in c and c++ there is a useful way to refresh an output line in printf
> and cout using \r meta command. So for example in the wget application
> the progress of the download is updated on the same output line of the
> screen. From an intital investigation python seems to lack this. Is
> this correct?
> 

>>> for i in range(10000):
...   print '\r',i,'and counting',
...
9999 and counting

(not obvious from the copy/paste of the output is that it also displayed 
the intervening numbers as it counted). The important thing is to end each 
print statement with a comma (or use sys.stdout.write).



More information about the Python-list mailing list