Kaydet (Commit) 9b550899 authored tarafından Ethan Furman's avatar Ethan Furman

Issue22780: reword NotImplemented docs to emphasise should

...@@ -26,9 +26,23 @@ A small number of constants live in the built-in namespace. They are: ...@@ -26,9 +26,23 @@ A small number of constants live in the built-in namespace. They are:
.. data:: NotImplemented .. data:: NotImplemented
Special value which should be returned by the special methods Special value which should be returned by the binary special methods
(:meth:`__eq__`, :meth:`__lt__`, :meth:`__add__`, etc.) to indicate (e.g. :meth:`__eq__`, :meth:`__lt__`, :meth:`__add__`, :meth:`__rsub__`,
that the operation is not implemented with respect to the other type. 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 .. data:: Ellipsis
......
...@@ -110,6 +110,8 @@ those. You can add ``MyFoo`` between :class:`Complex` and ...@@ -110,6 +110,8 @@ those. You can add ``MyFoo`` between :class:`Complex` and
MyFoo.register(Real) MyFoo.register(Real)
.. _implementing-the-arithmetic-operations:
Implementing the arithmetic operations Implementing the arithmetic operations
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
......
...@@ -154,11 +154,16 @@ NotImplemented ...@@ -154,11 +154,16 @@ NotImplemented
This type has a single value. There is a single object with this value. This This type has a single value. There is a single object with this value. This
object is accessed through the built-in name ``NotImplemented``. Numeric methods object is accessed through the built-in name ``NotImplemented``. Numeric methods
and rich comparison methods may return this value if they do not implement the and rich comparison methods should return this value if they do not implement the
operation for the operands provided. (The interpreter will then try the operation for the operands provided. (The interpreter will then try the
reflected operation, or some other fallback, depending on the operator.) Its reflected operation, or some other fallback, depending on the operator.) Its
truth value is true. truth value is true.
See
:ref:`implementing-the-arithmetic-operations`
for more details.
Ellipsis Ellipsis
.. index:: object: Ellipsis .. index:: object: Ellipsis
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment