[Python-ideas] except expression

spir denis.spir at gmail.com
Thu Feb 13 12:53:28 CET 2014


On 02/13/2014 12:36 PM, Paul Moore wrote:
> On 13 February 2014 11:25, spir<denis.spir at gmail.com>  wrote:
>> >I don't see any issue with:
>> >     phone = addressbook[name] except "Unknown" if KeyError
>> >     phone = addressbook[name] except "Unknown" if KeyError as e
>> >It is similar in syntax and meaning with if-expressions, with the first
>> >keyword 'except' obviously making all the difference we need.
> What I dislike about this variant is that in a normal try statement,
> the exception goes after the "except" keyword. Here, it's the
> alternative value that goes there. I find that very easy to misread.

You are right!

d


More information about the Python-ideas mailing list