Re: [Tutor] updating a print statement

2007-12-10 Thread Kent Johnson
This works for me: import sys import time for i in range(5): print '\rIndex =', i, sys.stdout.flush() time.sleep(1) Kent Bryan Fodness wrote: > I ran it both in IDLE and Command Prompt > > On Dec 10, 2007 5:02 PM, Kent Johnson <[EMAIL PROTECTED] > > wro

Re: [Tutor] updating a print statement

2007-12-10 Thread Bryan Fodness
It works now. Closed everything down and reopened. Thanks. On Dec 10, 2007 5:07 PM, Bryan Fodness <[EMAIL PROTECTED]> wrote: > I ran it both in IDLE and Command Prompt > > > On Dec 10, 2007 5:02 PM, Kent Johnson <[EMAIL PROTECTED]> wrote: > > > How are you running the program? > > > > Bryan Fod

Re: [Tutor] updating a print statement

2007-12-10 Thread Bryan Fodness
I ran it both in IDLE and Command Prompt On Dec 10, 2007 5:02 PM, Kent Johnson <[EMAIL PROTECTED]> wrote: > How are you running the program? > > Bryan Fodness wrote: > > > > for line in file('test.txt'): > > the_line = line.split() > > if the_line: > > if the_line[0] == 'Index': >

Re: [Tutor] updating a print statement

2007-12-10 Thread Kent Johnson
How are you running the program? Bryan Fodness wrote: > > for line in file('test.txt'): > the_line = line.split() > if the_line: > if the_line[0] == 'Index': > index = float(the_line[-1]) > print ("\rIndex = %.3f ") %index, > raw_input("\nExit") > Here is

Re: [Tutor] updating a print statement

2007-12-10 Thread Bryan Fodness
for line in file('test.txt'): the_line = line.split() if the_line: if the_line[0] == 'Index': index = float(the_line[-1]) print ("\rIndex = %.3f ") %index, raw_input("\nExit") Here is my output, Index = 0.000 Index = 0.400 Index = 0.800 Index = 1.000

Re: [Tutor] updating a print statement

2007-12-10 Thread Kent Johnson
Bryan Fodness wrote: > Here is the code. > > for line in file('test.txt'): > the_line = line.split() > if the_line: > if the_line[0] == 'Index': > index = float(the_line[-1]) > print ("\rIndex = %.3f") %index Add a comma at the end of the above line to sup

Re: [Tutor] updating a print statement

2007-12-10 Thread Bryan Fodness
Here is the code. for line in file('test.txt'): the_line = line.split() if the_line: if the_line[0] == 'Index': index = float(the_line[-1]) print ("\rIndex = %.3f") %index raw_input("\nExit") Here is the output. Index = 0.000 Index = 0.400 Index = 0.800 In

Re: [Tutor] updating a print statement

2007-12-10 Thread Kent Johnson
Bryan Fodness wrote: > I do want to overwrite the same line. > > I do not see a difference between using the \r and not using it. How are you running the program? Try it from a command line if that is not what you are doing. Can you show your new code? Kent PS Please Reply All to stay on the

Re: [Tutor] updating a print statement

2007-12-10 Thread Alan Gauld
"Bryan Fodness" <[EMAIL PROTECTED]> wrote > 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. If you use Linux t

Re: [Tutor] updating a print statement

2007-12-10 Thread Kent Johnson
Bryan Fodness wrote: > 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 rath

Re: [Tutor] updating a print statement

2007-12-10 Thread Luke Paireepinart
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 t

Re: [Tutor] updating a print statement

2007-12-10 Thread Ole Henning Jensen
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 vari

Re: [Tutor] updating a print statement

2007-12-10 Thread Ole Henning Jensen
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 i

[Tutor] updating a print statement

2007-12-10 Thread Bryan Fodness
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. Thanks,