On 10/19/06, Chris Hengge <[EMAIL PROTECTED]> wrote:
This works as well
file('filename.txt').readlines()[-1]
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.
I'd personally do something like this.
file = open(myfile, 'r')
fileContents = file.readlines() # read the entire document into memory for speed.
file.close()
print fileContents[-1] # This is the last line.
This works as well
file('filename.txt').readlines()[-1]
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.
_______________________________________________ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor