reference counting and file objects
Paul Rubin
http
Tue May 24 15:44:05 EDT 2005
"Martin v. Löwis" <martin at v.loewis.de> writes:
> > lines = file("myfile","r").readlines()
> >
> > have any better guarantee of being closed automatically?
>
> Yes. The file object only lives on the evaluation stack,
> and that is discarded in any case when the function terminates
> (whether through a return or through an exception). In
> addition, the object is released as soon as readlines
> returns.
It's released even if the exception is raised inside readlines?
More information about the Python-list
mailing list