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

Chris Angelico rosuav at gmail.com
Fri Feb 28 14:39:46 CET 2014


On Fri, Feb 28, 2014 at 11:51 PM, Nick Coghlan <ncoghlan at gmail.com> wrote:
>>> > Are there any other expressions that allow parens around a part of the
>>> > expression, without the stuff inside them becoming a completely
>>> > separate sub-expression?
>
> Also generator expressions and most uses of yield or yield from as
> embedded expressions. Parentheses are our general "this next bit may
> not be following the normal syntax rules" utility, in addition to
> being used to override the normal precedence rules (square brackets
> and curly braces similarly denote regions where the parsing rules may
> differ from the top level ones).

In those cases, the "stuff inside the parens" is the entire syntactic
structure of that sub-element, right? I was looking for something
where there's syntax inside and syntax outside the parens, where
what's in the parens isn't just an expression or tuple, so I could try
laying out an except expression to imitate that style. The function
call is excellent; removing one space from the layout did make the
expression look better, but as explained above, I still prefer the
current form. Would like to make the parens optional; maybe make them
mandatory if there are two except-expressions abutting, or something,
but I'd like to simplify the syntax for the common case. Otherwise,
current syntax is still my personal preferred.

Of course, we still have to convince Guido that this is a good idea at
all, syntax or no :)

ChrisA


More information about the Python-Dev mailing list