[Python-ideas] except expression

Chris Angelico rosuav at gmail.com
Wed Feb 19 03:26:29 CET 2014


On Wed, Feb 19, 2014 at 12:40 PM, Jan Kaliszewski <zuo at chopin.edu.pl> wrote:
>> 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.
>
>
> But then you must remember: in expression yes, in statement no;
> + additional trouble when you refactor transforming the former to
> the latter...

Perhaps. But I could imagine the need for parens being weakened in a
future version. Let's say 3.4/3.5 is billed as the primary target for
migration from 2.7, and that after 3.7, Python 3 will fly free and be
itself without worrying too much about how hard it is to port. (That
quite probably won't happen, but let's pretend.) In that case, 3.8
would be allowed to relax that restriction, which would then bring the
statement and expression forms in line. Alternatively, the expression
form could simply have the same arbitrary requirement, just for
consistency, and they could both lose it at once... or the expression
form could technically not require the parens, but style guides
recommend using them anyway, in case you need to change it to a
statement.

I'm generally not a fan of making parens mandatory. Let the style
guides argue that out.

ChrisA


More information about the Python-ideas mailing list