On Mon, Sep 21, 2015 at 4:47 PM, Random832
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.
Sorry, my bad. Indeed, x ?? y tries to fix the issue that "x or y" uses y if x is falsey. Still this seems a lesser problem to me than the problem solved by x?.a and x?[y]. Most of the time in my code it is actually fine to use the default if the LHS is an empty string. -- --Guido van Rossum (python.org/~guido)