On Sat, Feb 22, 2014 at 4:13 AM, Antoine Pitrou <solipsis@pitrou.net> wrote:
On Fri, 21 Feb 2014 09:37:29 -0800 Guido van Rossum <guido@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.