[Python-ideas] except expression

spir denis.spir at gmail.com
Thu Feb 13 13:11:23 CET 2014


On 02/13/2014 01:00 PM, Chris Angelico wrote:
> On Thu, Feb 13, 2014 at 10:54 PM, Ram Rachum <ram at rachum.com> wrote:
>> On Thu, Feb 13, 2014 at 1:50 PM, Chris Angelico <rosuav at gmail.com> wrote:
>>>
>>> On Thu, Feb 13, 2014 at 10:36 PM, Paul Moore <p.f.moore at gmail.com> wrote:
>>>> Personally, I quite like "EXPR except EXCEPTIONTYPE return VALUE" if
>>>> we have to stick with existing keywords. If I had free rein I might go
>>>> for a new keyword "then" instead of "return".
>>>
>>> Hmm. Stupid idea:
>>>
>>> EXPR expr EXCEPTIONTYPE pass VALUE
>>>
>>> Passing something is kinda like returning it, right? *ducks the rotten
>>> tomatoes*
>>
>> http://i.imgur.com/xk003.gif
>
> Do you mean my idea is win, or the notion of throwing rotten tomatoes
> at me is win? I'm inclined to the latter theory :)
>
> Oh, and that should be "EXPR except EXCEPTIONTYPE", of course. I
> wasn't sure if I'd clicked Send or not, edited, and reclicked Send, so
> you may have a corrected copy as well as that one. But you knew
> already what it ought to have been.

Your proposal has the big advantage of stating things in (the right) order:
    normal_value, special_condition, special_value
and it still lets the door open to naming the exception, using 'as', if later 
needed:
     EXPR except EXCEPTIONTYPE as EXCEPTIONNAME pass VALUE

d


More information about the Python-ideas mailing list