[Python-ideas] except expression

Stephen J. Turnbull stephen at xemacs.org
Sat Feb 15 10:03:06 CET 2014


Chris Angelico writes:
 > On Thu, Feb 13, 2014 at 3:57 PM, Stephen J. Turnbull <stephen at xemacs.org> wrote:
 > > Why not spell it the same way as in a try statement?
 > >
 > >     response_text = request('http://whatever.com').text except HttpError as "can't access data"

 > Compared to the block try/except syntax, "as" would have to mean "bind
 > the exception to this name before going into the exception-handling
 > block", which is quite different from your proposal.

True.

 > I can mention it in the PEP if you like, though.

No, please don't.  Your point kills it.

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".




More information about the Python-ideas mailing list