[Python-ideas] Null coalescing operator

Nikolaus Rath Nikolaus at rath.org
Wed Nov 2 15:32:50 EDT 2016


On Nov 02 2016, Zero Piraeus <schesis-Re5JQEeQqe8AvxtiuMwx3w at public.gmane.org> wrote:
> On Wed, 2016-11-02 at 08:46 -0700, Guido van Rossum wrote:
>> [...] we need to agree on what even the right definition of ?. is. It's
>> been frighteningly difficult to explain this even on this list, even
>> though I have a very clear view in my head, and PEP 505 also has the
>> same semantics and explains well why those are the right semantics.
>
> I think the proposed semantics for ?. are confusing (and the operator
> itself dangerous, but more on that later).
>
> If I write something like obj.attr, the failure mode I care about is that
> obj has no attribute attr, rather than that obj is specifically None (or
> one of a defined group of somewhat Nonelike objects).
>
> Clearly, in such a circumstance, obj is not what I expected it to be,
> because I thought it was going to have an attribute attr, and it
> doesn't. 

That means that you do not need null coalescing operators. They're not
intended for your use-case, and you are not the target audience.

Criticizing the proposal on this basis is like critizing it for not
helping with asynchronous I/O.

Best,
-Nikolaus

-- 
GPG encrypted emails preferred. Key id: 0xD113FCAC3C4E599F
Fingerprint: ED31 791B 2C5C 1613 AF38 8B8A D113 FCAC 3C4E 599F

             »Time flies like an arrow, fruit flies like a Banana.«


More information about the Python-ideas mailing list