Issue22780: reword NotImplemented docs to emphasise should

This commit is contained in:
Ethan Furman 2014-11-26 21:17:53 -08:00
commit 9b55089999
3 changed files with 25 additions and 4 deletions

View file

@ -26,9 +26,23 @@ A small number of constants live in the built-in namespace. They are:
.. data:: NotImplemented
Special value which should be returned by the special methods
(:meth:`__eq__`, :meth:`__lt__`, :meth:`__add__`, etc.) to indicate
that the operation is not implemented with respect to the other type.
Special value which should be returned by the binary special methods
(e.g. :meth:`__eq__`, :meth:`__lt__`, :meth:`__add__`, :meth:`__rsub__`,
etc.) to indicate that the operation is not implemented with respect to
the other type; may be returned by the in-place binary special methods
(e.g. :meth:`__imul__`, :meth:`__iand__`, etc.) for the same purpose.
Its truth value is true.
.. note::
When ``NotImplemented`` is returned, the interpreter will then try the
reflected operation on the other type, or some other fallback, depending
on the operator. If all attempted operations return ``NotImplemented``, the
interpreter will raise an appropriate exception.
See
:ref:`implementing-the-arithmetic-operations`
for more details.
.. data:: Ellipsis

View file

@ -110,6 +110,8 @@ those. You can add ``MyFoo`` between :class:`Complex` and
MyFoo.register(Real)
.. _implementing-the-arithmetic-operations:
Implementing the arithmetic operations
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~