On Fri, Jul 20, 2018 at 5:10 PM, Grégory Lielens
<gregory.liel...@gmail.com> wrote:
>
>
>> On 2018-07-19 02:11, Chris Angelico wrote:
>
>
>>
>> -snip-
>>         As far as I can see, these null-coalescing operators would break
>> that
>> model.  The PEP doesn't seem to provide for a "real" magic method
>> allowing users to override the actual behavior of the method.  (You can
>> only override __has_value__ to hook into it, but not define by fiat what
>> A ?? B does, as you can with other operators.)  And I think the reason
>> for this is that the operator itself is too specific, much more specific
>> in semantics than other operators.  (I had similar doubts about adding
>> the matrix-multiplication operator @.)
>>
>>         People keep saying that this null-coalescing behavior is so common
>> and
>> useful, etc., but that hasn't been my experience at all.  In my
>> experience, the desire to shortcut this kind of logic is more often a
>> sign of corner-cutting and insufficiently specified data formats, and is
>> likely to cause bugs later on.  Eventually it has to actually matter
>> whether something is None or not, and these operators just kick that can
>> down the road.  In terms of their abstract meaning, they are not
>> remotely close to as common or useful as operators like & and |.
>
>
> Fully agree with you on this

Excuse me, that wasn't my words you quoted. Watch your citations please :)

ChrisA
_______________________________________________
Python-ideas mailing list
Python-ideas@python.org
https://mail.python.org/mailman/listinfo/python-ideas
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to