[Python-ideas] With-expression

Sturla Molden sturla at molden.no
Tue Jan 20 14:00:31 CET 2009

On 1/20/2009 2:47 AM, Gregory P. Smith wrote:

>     I always preferred:
>     data = open("file.txt").read()
>     Which works all the way back as far as I can remember.
> In C Python yes that "works" but it makes absolutely no guarantees about 
> when that file is actually closed.  Don't write code that depends on a 
> particular GC behavior. 

Then why not introduce that guarantee? Indeterministic GC behaviour is a 
Jython and IronPython problem.

And if you are worried about not closing the file, why not close it 


More information about the Python-ideas mailing list