[Python-ideas] Null coalescing operators

Random832 random832 at fastmail.com
Tue Sep 22 01:47:13 CEST 2015

On Mon, Sep 21, 2015, at 17:48, Guido van Rossum wrote:
> This is important when x is a more complex expression that is either
> expensive or has a side-effect. E.g. d.get(key)?.upper() would currently
> have to be spelled as (some variant of) "None if d.get(key) is None else
> d.get(key).upper()" and the ?? operator doesn't really help for the
> repetition -- it would still be "d.get(key) ?? d.get(key).upper()".

?? is meant to use the right if the left *is* null, as I understand it.
So this isn't a problem it solves at all.

More information about the Python-ideas mailing list