[Tutor] Trying to extract the last line of a text file

Chris Hengge pyro9219 at gmail.com
Thu Oct 19 23:14:06 CEST 2006


Oh wow.. I totally missed that... nevermind.. ignore that question =D

On 10/19/06, Danny Yoo <dyoo at hkn.eecs.berkeley.edu> wrote:
>
>
> >> file('filename.txt').readlines()[-1]
>
> > Not to hijack the thread, but what stops you from just putting a
> > file.close() after your example line?
>
>
> Which file should file.close() close?  The problem is that we don't have a
> handle on the particular file we want to close off.
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.python.org/pipermail/tutor/attachments/20061019/3b776f4a/attachment.htm 


More information about the Tutor mailing list