bpo-41584: clarify when the reflected method of a binary arithemtic operator is called (#22505)
This commit is contained in:
parent
1fce240d6c
commit
d02d824e05
|
@ -2376,10 +2376,11 @@ left undefined.
|
||||||
|
|
||||||
.. note::
|
.. note::
|
||||||
|
|
||||||
If the right operand's type is a subclass of the left operand's type and that
|
If the right operand's type is a subclass of the left operand's type and
|
||||||
subclass provides the reflected method for the operation, this method will be
|
that subclass provides a different implementation of the reflected method
|
||||||
called before the left operand's non-reflected method. This behavior allows
|
for the operation, this method will be called before the left operand's
|
||||||
subclasses to override their ancestors' operations.
|
non-reflected method. This behavior allows subclasses to override their
|
||||||
|
ancestors' operations.
|
||||||
|
|
||||||
|
|
||||||
.. method:: object.__iadd__(self, other)
|
.. method:: object.__iadd__(self, other)
|
||||||
|
@ -2771,6 +2772,6 @@ An example of an asynchronous context manager class::
|
||||||
method—that will instead have the opposite effect of explicitly
|
method—that will instead have the opposite effect of explicitly
|
||||||
*blocking* such fallback.
|
*blocking* such fallback.
|
||||||
|
|
||||||
.. [#] For operands of the same type, it is assumed that if the non-reflected method
|
.. [#] For operands of the same type, it is assumed that if the non-reflected
|
||||||
(such as :meth:`__add__`) fails the operation is not supported, which is why the
|
method -- such as :meth:`__add__` -- fails then the overall operation is not
|
||||||
reflected method is not called.
|
supported, which is why the reflected method is not called.
|
||||||
|
|
Loading…
Reference in New Issue