[Python-ideas] PEP 505 (None coalescing operators) thoughts
carl at oddbird.net
Mon Sep 28 23:04:34 CEST 2015
On 09/28/2015 02:54 PM, Guido van Rossum wrote:
> If you want to dumb down the feature so that foo?.bar.baz means just
> (foo?.bar).baz then it's useless and I should just reject the PEP.
I think you're right that in practice ?. and ?[ would probably be just
fine, because the scope of their action is still quite limited.
But even if they are rejected, I think a simple `??` or `or?` (or
however it's spelled) operator to reduce the repetition of "x if x is
not None else y" is worth consideration on its own merits. This operator
is entirely unambiguous, and I think would be useful and frequently
used, whether or not ?. and ?[ are added along with it.
-------------- next part --------------
A non-text attachment was scrubbed...
Size: 836 bytes
Desc: OpenPGP digital signature
More information about the Python-ideas