[Python-ideas] except expression

Greg Ewing greg.ewing at canterbury.ac.nz
Thu Feb 13 22:31:48 CET 2014


Nick Coghlan wrote:
> "if" would be better, but, as you already noted, poses significant 
> parsing challenges (since it likely wouldn't be easy to require that 
> ternary expressions use parentheses in this new construct, but still 
> allow the parentheses to be omitted in the general case).

I don't think that would be an insurmountable difficulty.
The if-expression appears at the 'test' level in the grammar,
so all it should take is for the expression following
'except' to be something lower, such as an 'or_test'.

There are precedents for this kind of thing, e.g. yield
expressions can appear unparenthesised in some contexts
but not others.

-- 
Greg


More information about the Python-ideas mailing list