<div>It works now.</div>
<div> </div>
<div>Closed everything down and reopened.</div>
<div> </div>
<div>Thanks.<br><br></div>
<div class="gmail_quote">On Dec 10, 2007 5:07 PM, Bryan Fodness <<a href="mailto:bryan.fodness@gmail.com">bryan.fodness@gmail.com</a>> wrote:<br>
<blockquote class="gmail_quote" style="PADDING-LEFT: 1ex; MARGIN: 0px 0px 0px 0.8ex; BORDER-LEFT: #ccc 1px solid">I ran it both in IDLE and Command Prompt
<div>
<div></div>
<div class="Wj3C7c"><br><br>
<div class="gmail_quote">On Dec 10, 2007 5:02 PM, Kent Johnson <<a href="mailto:kent37@tds.net" target="_blank">kent37@tds.net</a>> wrote:<br>
<blockquote class="gmail_quote" style="PADDING-LEFT: 1ex; MARGIN: 0px 0px 0px 0.8ex; BORDER-LEFT: #ccc 1px solid">
<div>How are you running the program?<br><br></div>
<div>Bryan Fodness wrote:<br>><br>> for line in file('test.txt'):<br>> the_line = line.split()<br>> if the_line:<br>> if the_line[0] == 'Index':<br>> index = float(the_line[-1])
<br>> print ("\rIndex = %.3f ") %index,<br>> raw_input("\nExit")<br>> Here is my output,<br>><br>> Index = 0.000 Index = 0.400 Index = 0.800 Index = 1.000<br>><br>>
<br>> On Dec 10, 2007 4:48 PM, Kent Johnson <<a href="mailto:kent37@tds.net" target="_blank">kent37@tds.net</a><br></div>
<div>> <mailto:<a href="mailto:kent37@tds.net" target="_blank">kent37@tds.net</a>>> wrote:<br>><br>> Bryan Fodness wrote:<br>> > Here is the code.<br>> ><br>> > for line in file('
test.txt'):<br>> > the_line = line.split()<br>> > if the_line:<br>> > if the_line[0] == 'Index':<br>> > index = float(the_line[-1])<br>> > print ("\rIndex = %.3f") %index
<br>><br>> Add a comma at the end of the above line to suppress the newline that<br>> print normally outputs.<br>><br>> Kent<br>><br>> > raw_input("\nExit")<br>> >
<br>> > Here is the output.<br>> ><br>> > Index = 0.000<br>> > Index = 0.400<br>> > Index = 0.800<br>> > Index = 1.000<br>> ><br>> > Exit
<br>> ><br>> ><br>> > On Dec 10, 2007 4:33 PM, Kent Johnson <<a href="mailto:kent37@tds.net" target="_blank">kent37@tds.net</a><br>> <mailto:<a href="mailto:kent37@tds.net" target="_blank">
kent37@tds.net</a> ><br></div>
<div>
<div></div>
<div>> > <mailto:<a href="mailto:kent37@tds.net" target="_blank">kent37@tds.net</a> <mailto:<a href="mailto:kent37@tds.net" target="_blank">kent37@tds.net</a>>>> wrote:<br>> ><br>> > Bryan Fodness wrote:
<br>> > > I do want to overwrite the same line.<br>> > ><br>> > > I do not see a difference between using the \r and not<br>> using it.<br>> ><br>
> > How are you running the program? Try it from a command line<br>> if that is<br>> > not what you are doing. Can you show your new code?<br>> ><br>> > Kent<br>
> ><br>> > PS Please Reply All to stay on the list.<br>> ><br>> > ><br>> > > On Dec 10, 2007 2:43 PM, Kent Johnson <<a href="mailto:kent37@tds.net" target="_blank">
kent37@tds.net</a><br>> <mailto:<a href="mailto:kent37@tds.net" target="_blank">kent37@tds.net</a>><br>> > <mailto:<a href="mailto:kent37@tds.net" target="_blank">kent37@tds.net</a> <mailto:
<a href="mailto:kent37@tds.net" target="_blank"> kent37@tds.net</a>>><br>> > > <mailto:<a href="mailto:kent37@tds.net" target="_blank">kent37@tds.net</a> <mailto:<a href="mailto:kent37@tds.net" target="_blank">
kent37@tds.net</a>><br>> <mailto:<a href="mailto:kent37@tds.net" target="_blank"> kent37@tds.net</a> <mailto:<a href="mailto:kent37@tds.net" target="_blank">kent37@tds.net</a>>>>> wrote:<br>> > >
<br>> > > Bryan Fodness wrote:<br>> > > > I have a print statement in a for loop so I can <br>> watch the<br>> > progress<br>> > > >
<br>> > > > for line in file(file):<br>> > > > the_line = line.split()<br>> > > > if the_line:<br>> > > > print ("Index = %.2f") %index
<br>> > > ><br>> > > > Is there a way that only one line will be output <br>> and the<br>> > variable is<br>> > > > updated rather than one line for every index.
<br>> > ><br>> > > I'm not sure I understand what you are asking. index <br>> is never<br>> > > updated in<br>> > > the loop above.
<br>> > ><br>> > > If you want to overwrite the same line on the console, try <br>> > > print "\rIndex = %.2f" % index,<br>> > >
<br>> > > note ----^<br>> > > ---------------------------^<br>> > > <br>> > > You might need some extra spaces at the end of the
<br>> print to<br>> > 'erase' a<br>> > > longer previous line.<br>> > > <br>> > > Kent<br>> > ><br>> > >
<br>> > ><br>> > ><br>> > > --<br>> > > "The game of science can accurately be described as a <br>> never-ending<br>> > > insult to human intelligence." - Joćo Magueijo
<br>> ><br>> ><br>> ><br>> ><br>> > --<br>> > "The game of science can accurately be described as a never-ending <br>> > insult to human intelligence." - Joćo Magueijo
<br>><br>><br>><br>><br>> --<br>> "The game of science can accurately be described as a never-ending<br>> insult to human intelligence." - Joćo Magueijo <br><br></div></div></blockquote></div>
<br><br clear="all"><br></div></div>--
<div>
<div></div>
<div class="Wj3C7c"><br>"The game of science can accurately be described as a never-ending insult to human intelligence." - Joćo Magueijo </div></div></blockquote></div><br><br clear="all"><br>-- <br>"The game of science can accurately be described as a never-ending insult to human intelligence." - Joćo Magueijo