On 22/02/2014 16:36, Brett Cannon wrote:

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

    On Fri, 21 Feb 2014 09:37:29 -0800
    Guido van Rossum <gu...@python.org <mailto:gu...@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.

I read *except* as 'except if', and *:* as 'then' (often), so the main proposal reads naturally to me. I'm surprised to find others don't also, as that's the (only?) pronunciation that makes the familiar if-else and try-except constructs approximate English.

Isn't adding a new keyword (*then*) likely to be a big deal? There is the odd example of its use as an identifier, just in our test code:
http://hg.python.org/cpython/file/0695e465affe/Lib/test/test_epoll.py#l168
http://hg.python.org/cpython/file/0695e465affe/Lib/test/test_xmlrpc.py#l310

Jeff Allen
_______________________________________________
Python-Dev mailing list
Python-Dev@python.org
https://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
https://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com

Reply via email to