[Python-ideas] PEP 505 (None coalescing operators) thoughts

Carl Meyer 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...
Name: signature.asc
Type: application/pgp-signature
Size: 836 bytes
Desc: OpenPGP digital signature
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20150928/acaf41b0/attachment.sig>

More information about the Python-ideas mailing list