<br><br><div><span class="gmail_quote">On 10/19/06, <b class="gmail_sendername">Chris Hengge</b> <<a href="mailto:pyro9219@gmail.com">pyro9219@gmail.com</a>> wrote:</span><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
I'd personally do something like this. <br><br>file = open(myfile, 'r')<br>fileContents = file.readlines() # read the entire document into memory for speed.<br>file.close()<br><br>print fileContents[-1] # This is the last line.
</blockquote><div><br>This works as well<br><br>file('filename.txt').readlines()[-1]<br><br>Some will say that this is no good because the file is still open. However I've been told that when the object is cleaned the file is closed so it should be fine.
<br> </div><br></div><br>