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

Guido van Rossum guido at python.org
Fri Feb 21 18:37:29 CET 2014


On Fri, Feb 21, 2014 at 9:32 AM, Antoine Pitrou <solipsis at pitrou.net> wrote:

> On Sat, 22 Feb 2014 02:52:59 +1100
> Chris Angelico <rosuav at gmail.com> wrote:
>
> > On Sat, Feb 22, 2014 at 1:34 AM, Brett Cannon <brett at python.org> wrote:
> > > While I like the general concept, I agree that it looks too much like a
> > > crunched statement; the use of the colon is a non-starter for me. I'm
> sure
> > > I'm not the only one whose brain has been trained to view a colon in
> Python
> > > to mean "statement", period. This goes against that syntactic practice
> and
> > > just doesn't work for me.
> > >
> > > I'm -1 with the current syntax, but it can go into the + range if a
> better
> > > syntax can be chosen.
> >
> > We bikeshedded that extensively on -ideas. The four best options are:
> >
> > value = (expr except Exception: default)
>
> -0.5
>
> > value = (expr except Exception -> default)
>
> -0.5
>
> > value = (expr except Exception pass default)
>
> -1 (looks terribly weird)
>
> > value = (expr except Exception then default)
>
> +0.5
> But I'm aware it requires reserving "then" as a keyword, which might
> need a prior SyntaxWarning.
>

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').

I am going to sleep on this.

-- 
--Guido van Rossum (python.org/~guido)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-dev/attachments/20140221/7bf34464/attachment.html>


More information about the Python-Dev mailing list