This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: Inaccuracy about reflected operands in datamodel docs.
Type: Stage: patch review
Components: Documentation Versions:
process
Status: open Resolution:
Dependencies: Superseder:
Assigned To: docs@python Nosy List: docs@python, wim.glenn
Priority: normal Keywords: patch

Created on 2020-09-15 15:59 by wim.glenn, last changed 2022-04-11 14:59 by admin.

Pull Requests
URL Status Linked Edit
PR 22257 open wim.glenn, 2020-09-15 16:02
Messages (1)
msg376944 - (view) Author: wim glenn (wim.glenn) * Date: 2020-09-15 15:59
Qualifying that the right operand's type must be a *strict* subclass for the reflected method to take precedence avoids an edge case / counter-example when the types are actually equal.

    >>> class A:
    ...     def __add__(self, other):
    ...         print(1)
    ...     def __radd__(self, other):
    ...         print(2)
    ...
    >>> A() + A()
    1
    >>> issubclass(A, A)
    True
History
Date User Action Args
2022-04-11 14:59:35adminsetgithub: 85959
2020-09-15 16:02:51wim.glennsetkeywords: + patch
stage: patch review
pull_requests: + pull_request21312
2020-09-15 15:59:08wim.glenncreate