← Back to team overview

launchpad-dev team mailing list archive

Re: The with statement

 

On Feb 11, 2010, at 02:48 PM, Jeroen Vermeulen wrote:

>Barry Warsaw wrote:

>>     >>> with open('/etc/passwd') as a, open('/etc/group') as b:
>>     ...     pass
>
>That's very good news!  And this presumably takes care of the "what if 
>the second open() fails" and "what if b's cleanup depends on a being 
>there" corner-case stuff.  At this point it's not longer the thin layer 
>of sugar I had listed as an irrelevant gripe.

I'd have to look at the implementation to be sure, but I certainly hope so! :)

>So I still say: by all means use it, but let's stay away from 
>exception-dependent and exception-eating exit handlers for as long as we 
>can!

Good recommendation.
-Barry

Attachment: signature.asc
Description: PGP signature


References