readlines() question

Aahz Maruch aahz at netcom.com
Fri Jun 9 13:50:37 EDT 2000


In article <8hra5t$mfi$1 at pulp.srv.ualberta.ca>,
L Stewart  <liam at gpu.srv.ualberta.ca> wrote:
>Just out of curiosity, when something like the following is used,
>
>contents = open('file').readlines()
>
>is 'file' closed after readlines() finishes? If not, is it possible to
>somehow get either the file descriptor or the file object of the opened
>file? Thanks,

Yes, it's closed.  The anonymous object created by open() gets
deallocated after the assignment; part of the cleanup is to silently
call close().
--
                      --- Aahz (Copyright 2000 by aahz at netcom.com)

Androgynous poly kinky vanilla queer het    <*>     http://www.rahul.net/aahz/
Hugs and backrubs -- I break Rule 6

"I love you."
"Duhhhh!"  --SFJ



More information about the Python-list mailing list