A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://mail.python.org/pipermail/python-dev/2014-February/132615.html below:

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

[Python-Dev] PEP 463: Exception-catching expressions [Python-Dev] PEP 463: Exception-catching expressionsGreg Ewing greg.ewing at canterbury.ac.nz
Fri Feb 21 23:06:22 CET 2014
Nick Coghlan wrote:
> On 21 February 2014 13:15, Chris Angelico <rosuav at gmail.com> wrote:
> 
>>Generator expressions require parentheses, unless they would be
>>strictly redundant.  Ambiguities with except expressions could be
>>resolved in the same way, forcing nested except-in-except trees to be
>>correctly parenthesized 
> 
> I'd like to make the case that the PEP should adopt this as its
> default position.

I generally agree, but I'd like to point out that this
doesn't necessarily mean making the parenthesizing rules as
strict as they are for generator expressions.

The starting point for genexps is that the parens are part of
the syntax, the same way that square brackets are part of
the syntax of a list comprehension; we only allow them to
be omitted in very special circumstances.

On the other hand, I don't think there's any harm in allowing
an except expression to stand on its own when there is no
risk of ambiguity, e.g.

    foo = things[i] except IndexError: None

should be allowed, just as we allow

    x = a if b else c

and don't require

    x = (a if b else c)

-- 
Greg
More information about the Python-Dev mailing list

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4