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

Brett Cannon brett at python.org
Sat Feb 22 17:36:51 CET 2014


On Sat, Feb 22, 2014 at 4:13 AM, Antoine Pitrou <solipsis at pitrou.net> wrote:

> On Fri, 21 Feb 2014 09:37:29 -0800
> Guido van Rossum <guido at python.org> wrote:
> > I'm put off by the ':' syntax myself (it looks to me as if someone
> forgot a
> > newline somewhere) but 'then' feels even weirder (it's been hard-coded in
> > my brain as meaning the first branch of an 'if').
>
> Would 'else' work rather than 'then'?
>

thing = stuff['key'] except KeyError else None

That reads to me like the exception was silenced and only if there is no
exception the None is returned, just like an 'else' clause on a 'try'
statement.

I personally don't mind the 'then' as my brain has been hard-coded to mean
"the first branch of a statement" so it's looser than being explicitly
associated with 'if' but with any multi-clause statement.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-dev/attachments/20140222/782b20f9/attachment.html>


More information about the Python-Dev mailing list