[Tutor] updating a print statement

Luke Paireepinart rabidpoobear at gmail.com
Mon Dec 10 19:53:07 CET 2007


Ole Henning Jensen wrote:
> Sry about the previous mail.
>
> ----- Original Message ----- 
>
> I have a print statement in a for loop so I can watch the progress
>
> for line in file(file):
>     the_line = line.split()
>     if the_line:
>         print ("Index = %.2f") %index
>
> Is there a way that only one line will be output and the variable is updated
> rather than one line for every index.
You have to get into the console modules to do this.
Python doesn't have built-in support for modifying the terminal.
PyCurses can be used if you're on Linux (and presumably OS X?)
from Mark Hammond's Win32all module, you can use Win32.Console.
Both of these are fairly complicated from a beginner's standpoint, so 
I'd advise that you just don't worry about it.


More information about the Tutor mailing list