Printing/updating output to the screen

Josiah Carlson jcarlson at nospam.uci.edu
Fri Jan 30 03:43:07 EST 2004


Daniel Pryde wrote:

> Hi there. I hope this isn't a stupid question to ask, but does anyone 
> know how to print out a string without moving to a new line each time 
> and simply updating the first line. An example would be, if I wanted to 
> have a percentage progress counter that was constantly updating. I'm 
> unsure how to do this without printing to a brand new line. Any help 
> would be greatly appreciated. Thanks.
> 
> Daniel
> 

try this...

import time

for i in xrange(101):
     print i, '\r',
     time.sleep(.1)

  - Josiah



More information about the Python-list mailing list