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

Antoine Pitrou solipsis at pitrou.net
Sat Feb 22 10:23:54 CET 2014


On Fri, 21 Feb 2014 19:49:20 -0700
Eric Snow <ericsnowcurrently at gmail.com> wrote:
> On Fri, Feb 21, 2014 at 7:07 PM, Victor Stinner
> <victor.stinner at gmail.com> wrote:
> >> Consider this example of a two-level cache::
> >>     for key in sequence:
> >>         x = (lvl1[key] except KeyError: (lvl2[key] except KeyError: f(key)))
> >>         # do something with x
> >
> > ... but I don't like when it is used to build complex expressions.
> 
> This is true of any expression syntax, not just this proposal--though
> some expression syntax is more apt to be abused than others: you won't
> see many multiline int literals! ;)

But this is precisely why Python has refrained from making everything
an expression. For example, why assignements are not expressions.

Regards

Antoine.




More information about the Python-Dev mailing list