[Python-ideas] Null coalescing operator

David Mertz mertz at gnosis.cx
Sat Sep 10 18:21:25 EDT 2016


I find the '?.' syntax very ugly, much more so in the examples of chained
attributes.

A much better way to handle the use case is to wrap objects in a class that
gives this "propagating None" behavior with plain attribute access. A nice
implementation was presented in this thread.

On Sep 10, 2016 3:16 PM, "Random832" <random832 at fastmail.com> wrote:

> On Sat, Sep 10, 2016, at 13:26, Guido van Rossum wrote:
> > The way I recall it, we arrived at the perfect syntax (using ?) and
> > semantics. The issue was purely strong hesitation about whether
> > sprinkling ? all over your code is too ugly for Python
>
> I think that if there's "strong hesitation" about something being "too
> ugly" it can't really be described as "the perfect syntax". IIRC there
> were a couple alternatives being discussed that would have reduced the
> number of question marks to one [or one per object which might be None].
> _______________________________________________
> Python-ideas mailing list
> Python-ideas at python.org
> https://mail.python.org/mailman/listinfo/python-ideas
> Code of Conduct: http://python.org/psf/codeofconduct/
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20160910/348b0382/attachment.html>


More information about the Python-ideas mailing list