[Tutor] Reuse output line on stdout
Remco Gerlich
scarblac@pino.selwerd.nl
Tue, 16 Oct 2001 18:56:01 +0200
On 0, Bob Lunney <bob_lunney@yahoo.com> wrote:
> Total Python newbie here. I have a loop that reads
> and processes lines in a file. I want some feedback
> so I have my script print the line number under
> process to stdout. Since these files can contain
> several hundred thousand lines how do I get Python to
> reuse the same line on stdout, i.e. I don't want a
> newline/linefeed at the end of the output line, I just
> want to increment the line number on the input as it
> increments in my for loop. Any way to do this without
> resorting to Tkinter?
Depends on your platform.
On Linux/Unix terminals at least, you can print "\r" to go back to the
beginning of the line. Don't know if that works in DOS boxes on Windows.
--
Remco Gerlich