diff options
author | Ethan Furman <ethan@stoneleaf.us> | 2014-11-27 05:15:35 (GMT) |
---|---|---|
committer | Ethan Furman <ethan@stoneleaf.us> | 2014-11-27 05:15:35 (GMT) |
commit | b004943e9bca2f938b313172367a271f69aa29a5 (patch) | |
tree | 83e1f88812fb39181a691e076a686edc575ff6df | |
parent | e823933f9f625607c1c17bb5ac174a0c1595875d (diff) | |
download | cpython-b004943e9bca2f938b313172367a271f69aa29a5.zip cpython-b004943e9bca2f938b313172367a271f69aa29a5.tar.gz cpython-b004943e9bca2f938b313172367a271f69aa29a5.tar.bz2 |
(3.4) Issue22780: reword NotImplemented docs to emphasise should
-rw-r--r-- | Doc/library/constants.rst | 21 | ||||
-rw-r--r-- | Doc/library/numbers.rst | 2 | ||||
-rw-r--r-- | Doc/reference/datamodel.rst | 7 |
3 files changed, 26 insertions, 4 deletions
diff --git a/Doc/library/constants.rst b/Doc/library/constants.rst index 059a21d..42b5af2 100644 --- a/Doc/library/constants.rst +++ b/Doc/library/constants.rst @@ -26,9 +26,24 @@ A small number of constants live in the built-in namespace. They are: .. data:: NotImplemented - Special value which can be returned by the "rich comparison" special methods - (:meth:`__eq__`, :meth:`__lt__`, and friends), to indicate that the comparison - 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 diff --git a/Doc/library/numbers.rst b/Doc/library/numbers.rst index fec04ed..8ab07d0 100644 --- a/Doc/library/numbers.rst +++ b/Doc/library/numbers.rst @@ -110,6 +110,8 @@ those. You can add ``MyFoo`` between :class:`Complex` and MyFoo.register(Real) +.. _implementing-the-arithmetic-operations: + Implementing the arithmetic operations ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/Doc/reference/datamodel.rst b/Doc/reference/datamodel.rst index cbccb1e..43abf82 100644 --- a/Doc/reference/datamodel.rst +++ b/Doc/reference/datamodel.rst @@ -154,11 +154,16 @@ NotImplemented 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 - 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 reflected operation, or some other fallback, depending on the operator.) Its truth value is true. + See + :ref:`implementing-the-arithmetic-operations` + for more details. + + Ellipsis .. index:: object: Ellipsis |