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

Barry Warsaw barry at python.org
Tue Sep 29 19:35:42 CEST 2015


On Sep 28, 2015, at 03:04 PM, Carl Meyer wrote:

>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.

But why is it an improvement?  The ternary operator is entirely obvious and
readable, and at least in my experience, is rare enough that the repetition
doesn't hurt my fingers that much.  It seems like such a radical, ugly new
syntax unjustified by the frequency of use and readability improvement.

Cheers,
-Barry
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 819 bytes
Desc: OpenPGP digital signature
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20150929/d25c94fa/attachment.sig>


More information about the Python-ideas mailing list