[Python-ideas] except expression

Chris Angelico rosuav at gmail.com
Sat Feb 15 10:26:20 CET 2014


On Sat, Feb 15, 2014 at 8:03 PM, Stephen J. Turnbull <stephen at xemacs.org> wrote:
> My main thing is to avoid encouraging use of "may_raise() except
> ExcType as exc WHATEVER default_value".  I don't think an expression
> should return multiple values through separate channels this way, and
> as posted elsewhere I think use of exc *in* the expression is
> "complicated".

Understood, but I can well imagine there'll be plenty of cases where
it makes sense to fold "return value or exception message" into a
single value, possibly including a tag of some sort.

ret = urlopen(addr) except HTTPError as e pass "Oops - "+e.reason

So it makes good sense to grab the exception and use it in the expression.

Anyway, the PEP's written and submitted to the pep editors, so as soon
as something's posted, the bikeshedding can begin anew :)

ChrisA


More information about the Python-ideas mailing list