to close or not to close?

Remco Gerlich scarblac-spamtrap at pino.selwerd.nl
Mon Jul 31 18:57:50 EDT 2000


Grant Griffin wrote in comp.lang.python:
> Forgive me if this is a FAQ, but is it considered good Python form to close a
> file whose variable is just about to go out of scope (and thus be automatically
> closed)?  Or should one just omit that?

Close it. Explicit is better than implicit, and you don't rely on the
__del__ method being called - for instance, in JPython the file wouldn't be
closed (afaik).

-- 
Remco Gerlich,  scarblac at pino.selwerd.nl

   This is no way to be
     Man ought to be free      -- Ted Bundy
       That man should be me



More information about the Python-list mailing list