[Python-ideas] with ... except

Antoine Pitrou solipsis at pitrou.net
Fri Mar 8 14:37:50 CET 2013


Le Fri, 8 Mar 2013 21:43:52 +1000,
Nick Coghlan <ncoghlan at gmail.com> a
écrit :
> The defined semantics of a with statement already include three of
> those clauses (try, except, finally). Does the except clause still
> fire if the with statement suppresses the exception?

No, it doesn't.

> With the nested
> form, the answer is clearly yes. With the flattened form, the answer
> is less obvious. Furthermore, if the with statement allows "except",
> does it also allow else and finally? If not, why not?

It doesn't, simply because I don't need it :-)
(but, yes, that would be a reasonable request too)

> It *is* annoying that composing with statements with explicit
> exception handling is somewhat clumsy, but I don't think this is the
> way to fix it.

Yep, I think we will eventually have to propose something to fix that,
er, "wart" :-)

Regards

Antoine.





More information about the Python-ideas mailing list