<div>Here is the code.</div>
<div> </div>
<div>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
</div>
<div>raw_input("\nExit")</div>
<div> </div>
<div>Here is the output.</div>
<div><br>Index = 0.000</div>
<div>Index = 0.400</div>
<div>Index = 0.800</div>
<div>Index = 1.000</div>
<div> </div>
<div>Exit<br><br><br></div>
<div class="gmail_quote">On Dec 10, 2007 4:33 PM, Kent Johnson <<a href="mailto:kent37@tds.net">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 class="Ih2E3d">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 using it.<br><br></div>How are you running the program? Try it from a command line if that is
<br>not what you are doing. Can you show your new code?<br><font color="#888888"><br>Kent<br></font><br>PS Please Reply All to stay on the list.<br>
<div class="Ih2E3d"><br>><br>> On Dec 10, 2007 2:43 PM, Kent Johnson <<a href="mailto:kent37@tds.net">kent37@tds.net</a><br></div>
<div>
<div></div>
<div class="Wj3C7c">> <mailto:<a href="mailto:kent37@tds.net">kent37@tds.net</a>>> wrote:<br>><br>> Bryan Fodness wrote:<br>> > I have a print statement in a for loop so I can watch the 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 and the variable is<br>> > updated rather than one line for every index.<br>><br>> I'm not sure I understand what you are asking. index 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 print to '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 never-ending<br>> insult to human intelligence." - Joćo Magueijo<br><br></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