[Python-ideas] except expression

Chris Angelico rosuav at gmail.com
Wed Feb 19 02:11:15 CET 2014


On Wed, Feb 19, 2014 at 11:19 AM, Jan Kaliszewski <zuo at chopin.edu.pl> wrote:
> 18.02.2014 17:25, Paul Moore napisał:
>
>
>> OTOH, there's still an argument for only allowing a single exception
>> name in the syntax (an "identifier" rather than an "expression" in
>> syntax terms). If you must catch multiple exceptions, give the
>> relevant tuple a name.
>
>
> I believe that at this point (what the exception spec would be
> allowed to be: identifier?, tuple?, any expression?) the syntax should
> be identical to the statement syntax (i.e.: any expression).
>
> Less special cases to remember.

Yes, definitely. I see little value in forcing single-exception catching.

> For the same reason, I believe that tuple expressions
> ("except (ValueError, TypeError)") should be obligatorily
> enclosed with parens as long as they are obligatorily enclosed
> with parens in the statement syntax (i.e., probably till Python 3.13
> :)).

AFAIK, the only reason to mandate the parens is to specifically
disallow the Py2 syntax:

except Exception, e:
    pass

If that's the case, they could be optional in the expression form, as
that has no Py2 equivalent.

ChrisA


More information about the Python-ideas mailing list