8000 bpo-41706: Fix dunder operator invocation docs by wchargin · Pull Request #22084 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content

bpo-41706: Fix dunder operator invocation docs #22084

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions Doc/reference/datamodel.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2330,7 +2330,7 @@ left undefined.
(``+``, ``-``, ``*``, ``@``, ``/``, ``//``, ``%``, :func:`divmod`,
:func:`pow`, ``**``, ``<<``, ``>>``, ``&``, ``^``, ``|``). For instance, to
evaluate the expression ``x + y``, where *x* is an instance of a class that
has an :meth:`__add__` method, ``x.__add__(y)`` is called. The
has an :meth:`__add__` method, ``type(x).__add__(x, y)`` is called. The
:meth:`__divmod__` method should be the equivalent to using
:meth:`__floordiv__` and :meth:`__mod__`; it should not be related to
:meth:`__truediv__`. Note that :meth:`__pow__` should be defined to accept
Expand Down Expand Up @@ -2366,8 +2366,9 @@ left undefined.
(swapped) operands. These functions are only called if the left operand does
not support the corresponding operation [#]_ and the operands are of different
types. [#]_ For instance, to evaluate the expression ``x - y``, where *y* is
an instance of a class that has an :meth:`__rsub__` method, ``y.__rsub__(x)``
is called if ``x.__sub__(y)`` returns *NotImplemented*.
an instance of a class that has an :meth:`__rsub__` method,
``type(y).__rsub__(y, x)`` is called if ``type(x).__sub__(x, y)`` returns
*NotImplemented*.

.. index:: builtin: pow

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Fix docs about how methods like ``__add__`` are invoked when evaluating
operator expressions.
0