Q on explicitly calling file.close

r rt8396 at gmail.com
Sat Sep 5 17:52:23 EDT 2009


On Sep 5, 2:47 pm, Dennis Lee Bieber <wlfr... at ix.netcom.com> wrote:
(snip)
> > Finally, I was under the impression that Python closed filehandles
> > automatically when they were garbage-collected.  (In fact (3)
> > suggests as much, since it does not include an implicit call to
> > fh.close.) If so, the difference between (1) and (3) does not seem
> > very big.  What am I missing here?

True, but i find the with statement (while quite useful in general
practice) is not a "cure all" for situations that need and exception
caught. In that case the laborious finger wrecking syntax of "f.close
()" must be painstaking typed letter by painful letter.

f-.-c-l-o-s-e-(-)

It's just not fair ;-(



More information about the Python-list mailing list