On Fri, Feb 21, 2014 at 8:41 PM, Greg Ewing <greg.ew...@canterbury.ac.nz>wrote:

> Ethan Furman wrote:
>
>> On 02/21/2014 03:29 PM, Greg Ewing wrote:
>>
>>      value = lst[2] except "No value" if IndexError
>>>
>>
>> It does read nicely, and is fine for the single, non-nested, case (which
>> is probably the vast majority), but how would it handle nested exceptions?
>>
>
> Hmmm, probably not very well, unless we define
>
>    a except b if E1 except c if E2
>
> to mean
>
>    a except (b except c if E2) if E1
>
> If E1 == E2, that could perhaps be abbreviated to
>
>    a except b except c if E
>
> Or we could just decide that the nested case is going
> to be so rare it's not worth worrying about.


+1 on not caring. Keep the expression for simple, obvious cases of a single
exception type and fall back to the statement for fancier use (just like
listcomps). The focus should be ease of expressiveness for a common
pattern, not trying to convert tons of try/except statements into an
expression just because we can.
_______________________________________________
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