open, close

Manfred Lotz ml_news at posteo.de
Sun Sep 1 12:41:07 EDT 2019


On Sun, 1 Sep 2019 16:46:44 +0100
Barry <barry at barrys-emacs.org> wrote:

> > On 31 Aug 2019, at 15:41, Manfred Lotz <ml_news at posteo.de> wrote:
> > 
> > When you say COULD this sounds like it is a matter of luck. My
> > thinking was that USUALLY the file will be closed after the
> > statement because then the file handle goes out of scope.  
> 
> It all depends on the way any python implementation does its garbage
> collection. The file is closed as a side effect of deleting the file
> object to reclaiming the memory of the file object.
> 
> At the start of python 3 people where suprised when files and other
> resources where not released at the same time that python 2 released
> them.
> 

Thanks for this. Very interesting.



-- 
Manfred




More information about the Python-list mailing list