[Tutor] Trying to extract the last line of a text file
Chris Hengge
pyro9219 at gmail.com
Thu Oct 19 21:17:09 CEST 2006
Not to hijack the thread, but what stops you from just putting a file.close()
after your example line?
On 10/19/06, Chad Crabtree <flaxeater at gmail.com> wrote:
>
> 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 at python.org
> http://mail.python.org/mailman/listinfo/tutor
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.python.org/pipermail/tutor/attachments/20061019/27428c89/attachment.html
More information about the Tutor
mailing list