[Python-Dev] PEP 463: Exception-catching expressions
greg.ewing at canterbury.ac.nz
Sat Feb 22 00:29:59 CET 2014
Antoine Pitrou wrote:
>> lst = [1, 2]
>> value = lst except IndexError: "No value"
> the gain in concision is counterbalanced by a loss in
This version might be more readable:
value = lst except "No value" if IndexError
since it puts the normal and exceptional values next
to each other, and relegates the exception type (which
is of much less interest) to a trailing aside.
More information about the Python-Dev