Q on explicitly calling file.close

r rt8396 at gmail.com
Mon Sep 7 01:31:54 CEST 2009


On Sep 6, 1:14 pm, "Jan Kaliszewski" <z... at chopin.edu.pl> wrote:
> 05-09-2009 r <rt8... at gmail.com> wrote:
> > i find the with statement (while quite useful in general
> > practice) is not a "cure all" for situations that need and exception
> > caught.
>
> In what sense?

*ahem*! in the sense that the with statement (while quite useful in
general practice) is not a "cure all" for situations that need and
exception caught ;-)

> I think that:
>
>     with open(...) as f:
>        foo...
>
> is equivalent to:
>
>     f = open(...)
>     try:
>         foo...
>     finally:
>         f.close()
>
> Obviously it doesn't substitute catching with 'except'

My sentiments exactly...?


Get Enlightened -> http://jjsenlightenments.blogspot.com/




More information about the Python-list mailing list