[Python-Dev] PEP 463: Exception-catching expressions

Chris Angelico rosuav at gmail.com
Fri Feb 21 16:03:07 CET 2014

On Sat, Feb 22, 2014 at 1:59 AM, Chris Angelico <rosuav at gmail.com> wrote:
> I've spent the better part of the last hour debating this in my head.
> It's basically a question of simplicity versus future flexibility:
> either keep the syntax clean and deny the multiple-except-clause
> option, or mandate the parens and permit it. The first option has, in
> my own head, the stronger case - this is designed for simplicity, and
> it wouldn't be that big a deal to completely reject multiple except
> clauses and simply require that the

Oops, hit the wrong key and sent that half-written.

... and simply require that the statement form be used. But the
whelming opinion of python-dev seems to be in favour of the parens
anyway, and since they give us the possibility of future expansion
effectively for free, I've gone that way. Parens are now required; the
syntax is:

value = (expr except Exception: default)

and, as per genexp rules, redundant parens can be omitted:

print(lst[i] except IndexError: "Out of bounds")


More information about the Python-Dev mailing list