Skip to content

Commit bf5e106

Browse files
authored
doc: Mention the missing reflected special methods for all binary operations (GH-119931)
1 parent 010ea93 commit bf5e106

File tree

1 file changed

+17
-7
lines changed

1 file changed

+17
-7
lines changed

Doc/reference/expressions.rst

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1211,7 +1211,8 @@ Raising ``0.0`` to a negative power results in a :exc:`ZeroDivisionError`.
12111211
Raising a negative number to a fractional power results in a :class:`complex`
12121212
number. (In earlier versions it raised a :exc:`ValueError`.)
12131213

1214-
This operation can be customized using the special :meth:`~object.__pow__` method.
1214+
This operation can be customized using the special :meth:`~object.__pow__` and
1215+
:meth:`~object.__rpow__` methods.
12151216

12161217
.. _unary:
12171218

@@ -1299,6 +1300,9 @@ This operation can be customized using the special :meth:`~object.__mul__` and
12991300
The ``@`` (at) operator is intended to be used for matrix multiplication. No
13001301
builtin Python types implement this operator.
13011302

1303+
This operation can be customized using the special :meth:`~object.__matmul__` and
1304+
:meth:`~object.__rmatmul__` methods.
1305+
13021306
.. versionadded:: 3.5
13031307

13041308
.. index::
@@ -1314,8 +1318,10 @@ integer; the result is that of mathematical division with the 'floor' function
13141318
applied to the result. Division by zero raises the :exc:`ZeroDivisionError`
13151319
exception.
13161320

1317-
This operation can be customized using the special :meth:`~object.__truediv__` and
1318-
:meth:`~object.__floordiv__` methods.
1321+
The division operation can be customized using the special :meth:`~object.__truediv__`
1322+
and :meth:`~object.__rtruediv__` methods.
1323+
The floor division operation can be customized using the special
1324+
:meth:`~object.__floordiv__` and :meth:`~object.__rfloordiv__` methods.
13191325

13201326
.. index::
13211327
single: modulo
@@ -1340,7 +1346,8 @@ also overloaded by string objects to perform old-style string formatting (also
13401346
known as interpolation). The syntax for string formatting is described in the
13411347
Python Library Reference, section :ref:`old-string-formatting`.
13421348

1343-
The *modulo* operation can be customized using the special :meth:`~object.__mod__` method.
1349+
The *modulo* operation can be customized using the special :meth:`~object.__mod__`
1350+
and :meth:`~object.__rmod__` methods.
13441351

13451352
The floor division operator, the modulo operator, and the :func:`divmod`
13461353
function are not defined for complex numbers. Instead, convert to a floating
@@ -1367,7 +1374,8 @@ This operation can be customized using the special :meth:`~object.__add__` and
13671374
The ``-`` (subtraction) operator yields the difference of its arguments. The
13681375
numeric arguments are first converted to a common type.
13691376

1370-
This operation can be customized using the special :meth:`~object.__sub__` method.
1377+
This operation can be customized using the special :meth:`~object.__sub__` and
1378+
:meth:`~object.__rsub__` methods.
13711379

13721380

13731381
.. _shifting:
@@ -1388,8 +1396,10 @@ The shifting operations have lower priority than the arithmetic operations:
13881396
These operators accept integers as arguments. They shift the first argument to
13891397
the left or right by the number of bits given by the second argument.
13901398

1391-
This operation can be customized using the special :meth:`~object.__lshift__` and
1392-
:meth:`~object.__rshift__` methods.
1399+
The left shift operation can be customized using the special :meth:`~object.__lshift__`
1400+
and :meth:`~object.__rlshift__` methods.
1401+
The right shift operation can be customized using the special :meth:`~object.__rshift__`
1402+
and :meth:`~object.__rrshift__` methods.
13931403

13941404
.. index:: pair: exception; ValueError
13951405

0 commit comments

Comments
 (0)