Q on explicitly calling file.close

r rt8396 at gmail.com
Sun Sep 6 19:31:54 EDT 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