[Python-ideas] Fwd: Null coalescing operator
Random832
random832 at fastmail.com
Sat Sep 10 22:38:59 EDT 2016
On Sat, Sep 10, 2016, at 20:15, David Mertz wrote:
> On Sep 10, 2016 4:45 PM, "Guido van Rossum" <guido at python.org> wrote:
> >
> > There seems to be a major misunderstanding here. A None-coalescing
> > operator is not for catching AttributeError, it's a shortcut similar
> > to "a or b" except that it checks for "a is None" rather than bool(a).
To put it more explicitly, more similar to "a and a.b"
> This really MUST BE essentially a way a catching AttributeErrors though.
> With the proposed syntax 'x?.foo?.bar' will resolve even if x has no
> 'foo'.
Why? I think you're confusing this proposal for something else. This is
for treating x is None specially, not simply catching AttributeError to
deal with the fact that None.foo doesn't exist.
More information about the Python-ideas
mailing list