summaryrefslogtreecommitdiffstats
path: root/Doc
diff options
context:
space:
mode:
authorPaulo Freitas <me@paulofreitas.me>2024-06-04 17:55:11 (GMT)
committerGitHub <noreply@github.com>2024-06-04 17:55:11 (GMT)
commitbf5e1065f4ec2077c6ca352fc1ad940a76d1f6c9 (patch)
tree504cff35f1ba2b44d1416b37648e4ff4ac81cdd3 /Doc
parent010ea93b2b888149561becefeee90826bf8a2934 (diff)
downloadcpython-bf5e1065f4ec2077c6ca352fc1ad940a76d1f6c9.zip
cpython-bf5e1065f4ec2077c6ca352fc1ad940a76d1f6c9.tar.gz
cpython-bf5e1065f4ec2077c6ca352fc1ad940a76d1f6c9.tar.bz2
doc: Mention the missing reflected special methods for all binary operations (GH-119931)
Diffstat (limited to 'Doc')
-rw-r--r--Doc/reference/expressions.rst24
1 files changed, 17 insertions, 7 deletions
diff --git a/Doc/reference/expressions.rst b/Doc/reference/expressions.rst
index 00b57ef..872773f 100644
--- a/Doc/reference/expressions.rst
+++ b/Doc/reference/expressions.rst
@@ -1211,7 +1211,8 @@ Raising ``0.0`` to a negative power results in a :exc:`ZeroDivisionError`.
Raising a negative number to a fractional power results in a :class:`complex`
number. (In earlier versions it raised a :exc:`ValueError`.)
-This operation can be customized using the special :meth:`~object.__pow__` method.
+This operation can be customized using the special :meth:`~object.__pow__` and
+:meth:`~object.__rpow__` methods.
.. _unary:
@@ -1299,6 +1300,9 @@ This operation can be customized using the special :meth:`~object.__mul__` and
The ``@`` (at) operator is intended to be used for matrix multiplication. No
builtin Python types implement this operator.
+This operation can be customized using the special :meth:`~object.__matmul__` and
+:meth:`~object.__rmatmul__` methods.
+
.. versionadded:: 3.5
.. index::
@@ -1314,8 +1318,10 @@ integer; the result is that of mathematical division with the 'floor' function
applied to the result. Division by zero raises the :exc:`ZeroDivisionError`
exception.
-This operation can be customized using the special :meth:`~object.__truediv__` and
-:meth:`~object.__floordiv__` methods.
+The division operation can be customized using the special :meth:`~object.__truediv__`
+and :meth:`~object.__rtruediv__` methods.
+The floor division operation can be customized using the special
+:meth:`~object.__floordiv__` and :meth:`~object.__rfloordiv__` methods.
.. index::
single: modulo
@@ -1340,7 +1346,8 @@ also overloaded by string objects to perform old-style string formatting (also
known as interpolation). The syntax for string formatting is described in the
Python Library Reference, section :ref:`old-string-formatting`.
-The *modulo* operation can be customized using the special :meth:`~object.__mod__` method.
+The *modulo* operation can be customized using the special :meth:`~object.__mod__`
+and :meth:`~object.__rmod__` methods.
The floor division operator, the modulo operator, and the :func:`divmod`
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
The ``-`` (subtraction) operator yields the difference of its arguments. The
numeric arguments are first converted to a common type.
-This operation can be customized using the special :meth:`~object.__sub__` method.
+This operation can be customized using the special :meth:`~object.__sub__` and
+:meth:`~object.__rsub__` methods.
.. _shifting:
@@ -1388,8 +1396,10 @@ The shifting operations have lower priority than the arithmetic operations:
These operators accept integers as arguments. They shift the first argument to
the left or right by the number of bits given by the second argument.
-This operation can be customized using the special :meth:`~object.__lshift__` and
-:meth:`~object.__rshift__` methods.
+The left shift operation can be customized using the special :meth:`~object.__lshift__`
+and :meth:`~object.__rlshift__` methods.
+The right shift operation can be customized using the special :meth:`~object.__rshift__`
+and :meth:`~object.__rrshift__` methods.
.. index:: pair: exception; ValueError