On Thu, Feb 13, 2014 at 3:57 PM, Stephen J. Turnbull <stephen@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"
The "as" clause would be required, so "as" always binds to the immediately preceding "except", and iterated it should associate as "(this except ErrorA as that) except ErrorB as other" rather than "this except ErrorA as (that except ErrorB as other)" IMO.
I don't think it reads very well, though. The statement form (1) emphasizes the main operation compared to the "try", and (2) suggests that catching an exception is quite a heavy operation compared to execution without an exception, which is true.
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. I can mention it in the PEP if you like, though. ChrisA