diff options
author | R David Murray <rdmurray@bitdance.com> | 2014-03-09 22:51:35 (GMT) |
---|---|---|
committer | R David Murray <rdmurray@bitdance.com> | 2014-03-09 22:51:35 (GMT) |
commit | 6ae5eef5429e8663024ad32c6f38c89f9171aea0 (patch) | |
tree | ca3dcb0b13a22e2499d7e3f12963e2dbe46ce123 /Doc/reference | |
parent | c4025770565116a5150cc22224053f8e7f392cb1 (diff) | |
parent | 14d7b718bacb6b8a0702489d04895ea4e4b11131 (diff) | |
download | cpython-6ae5eef5429e8663024ad32c6f38c89f9171aea0.zip cpython-6ae5eef5429e8663024ad32c6f38c89f9171aea0.tar.gz cpython-6ae5eef5429e8663024ad32c6f38c89f9171aea0.tar.bz2 |
Merge #19953: Clarify the wording of the augmented assignment discussion.
Diffstat (limited to 'Doc/reference')
-rw-r--r-- | Doc/reference/datamodel.rst | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/Doc/reference/datamodel.rst b/Doc/reference/datamodel.rst index 597e04e..8204dc3 100644 --- a/Doc/reference/datamodel.rst +++ b/Doc/reference/datamodel.rst @@ -2050,11 +2050,13 @@ left undefined. ``&=``, ``^=``, ``|=``). These methods should attempt to do the operation in-place (modifying *self*) and return the result (which could be, but does not have to be, *self*). If a specific method is not defined, the augmented - assignment falls back to the normal methods. For instance, to execute the - statement ``x += y``, where *x* is an instance of a class that has an - :meth:`__iadd__` method, ``x.__iadd__(y)`` is called. If *x* is an instance - of a class that does not define a :meth:`__iadd__` method, ``x.__add__(y)`` - and ``y.__radd__(x)`` are considered, as with the evaluation of ``x + y``. + assignment falls back to the normal methods. For instance, if *x* is an + instance of a class with an :meth:`__iadd__` method, ``x += y`` is equivalent + to ``x = x.__iadd__(y)`` . Otherwise, ``x.__add__(y)`` and ``y.__radd__(x)`` + are considered, as with the evaluation of ``x + y``. In certain situations, + augmented assignment can result in unexpected errors (see + :ref:`faq-augmented-assignment-tuple-error`), but this behavior is in + fact part of the data model. .. method:: object.__neg__(self) |