[Python-ideas] except expression
Greg Ewing
greg.ewing at canterbury.ac.nz
Tue Feb 18 23:21:43 CET 2014
Alexander Belopolsky wrote:
> For example, it would be nice to be able to write something like
>
> x = d1[key] except d2[key] except 0
>
> but sprinkle this with repeated KeyError and what is important (d1 and
> d2) will be lost in the scaffolding.
Another crazy thought: Make the default exception depend
on what kind of expression the except clause is attached
to.
things[i] except: default # catches LookupError
distance / time except: very_fast # catches ZeroDivisionError
Anything else would require an explicit exception type.
--
Greg
More information about the Python-ideas
mailing list