readlines() question

Moshe Zadka moshez at math.huji.ac.il
Fri Jun 9 14:05:35 EDT 2000


[About...]
> >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,

[Aahz] 
> Yes, it's closed.  The anonymous object created by open() gets
> deallocated after the assignment; part of the cleanup is to silently
> call close().

While what Aahz said can't be said to be untrue, it's hard to call it
true, either. That is what happens in the *current* *CPython*
implementation. In no way does the language require it, and specifically,
for JPython, it is not true.

just-picking-nits-here-people-ly y'rs, Z.
--
Moshe Zadka <moshez at math.huji.ac.il>
http://www.oreilly.com/news/prescod_0300.html
http://www.linux.org.il -- we put the penguin in .com





More information about the Python-list mailing list