[Python-ideas] PEP 505: None-aware operators

Stephan Houben stephanh42 at gmail.com
Thu Jul 19 14:45:01 EDT 2018


Let me just address this point:

2018-07-19 20:36 GMT+02:00 Brendan Barnwell <brenbarn at brenbarn.net>:

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

I think the actual reason is that it is a short-cutting operator, and none
of
the shortcutting operators (and, or,  if/else) have an associated method.
They cannot have, since they induce a non-standard evaluation order,
hence their effect cannot be emulated with a method invocation.

Stephan
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20180719/bb8da553/attachment.html>


More information about the Python-ideas mailing list