Skip to content

Commit 2713c2a

Browse files
GouvernathorCAM-GerlachJelleZijlstra
authored
gh-104219: Document that idunders can return NotImplemented (#104220)
Co-authored-by: C.A.M. Gerlach <[email protected]> Co-authored-by: Jelle Zijlstra <[email protected]>
1 parent fee86fd commit 2713c2a

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

Doc/reference/datamodel.rst

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3044,10 +3044,12 @@ left undefined.
30443044
(``+=``, ``-=``, ``*=``, ``@=``, ``/=``, ``//=``, ``%=``, ``**=``, ``<<=``,
30453045
``>>=``, ``&=``, ``^=``, ``|=``). These methods should attempt to do the
30463046
operation in-place (modifying *self*) and return the result (which could be,
3047-
but does not have to be, *self*). If a specific method is not defined, the
3047+
but does not have to be, *self*). If a specific method is not defined, or if
3048+
that method returns :data:`NotImplemented`, the
30483049
augmented assignment falls back to the normal methods. For instance, if *x*
30493050
is an instance of a class with an :meth:`__iadd__` method, ``x += y`` is
3050-
equivalent to ``x = x.__iadd__(y)`` . Otherwise, ``x.__add__(y)`` and
3051+
equivalent to ``x = x.__iadd__(y)`` . If :meth:`__iadd__` does not exist, or if ``x.__iadd__(y)``
3052+
returns :data:`!NotImplemented`, ``x.__add__(y)`` and
30513053
``y.__radd__(x)`` are considered, as with the evaluation of ``x + y``. In
30523054
certain situations, augmented assignment can result in unexpected errors (see
30533055
:ref:`faq-augmented-assignment-tuple-error`), but this behavior is in fact

0 commit comments

Comments
 (0)