[Python-ideas] Fwd: Null coalescing operator
Ethan Furman
ethan at stoneleaf.us
Mon Sep 12 03:27:00 EDT 2016
On 09/12/2016 12:05 AM, Michel Desmoulin wrote:
> There is also an alternative to this operator, and it's allowing a
> shortcut to do:
>
> try:
> val = do_thing()
> except ThingError:
> val = "default"
>
> In the form of:
>
> val = do_thing() except ThingError: "default"
>
> I was debated, and rejected, but I feel like mentioning it again because
> it has some strong benefits.
+1
There are many places in my code where this would clean things up a bit. Not having it is like not having list comps or not having the ternary if-else -- possible, but it would be much nicer to have it.
--
~Ethan~
More information about the Python-ideas
mailing list