[Python-ideas] Fwd: Null coalescing operator

Random832 random832 at fastmail.com
Tue Sep 13 10:22:43 EDT 2016


On Tue, Sep 13, 2016, at 08:44, Michel Desmoulin wrote:
> You won't see very complex usages, mostly things like:
> 
> val = foo[-1] except IndexError: "bar"
> doh = val.attr.other except AttributeError: "default"

It occurs to me that if lambda were more lightweight [whether it's the
syntax or the implementation that's the problem is unclear], not only
this but also the ternary operator could have been functions.

val = iexcept(lambda: foo[-1], IndexError, lambda: "bar")


More information about the Python-ideas mailing list