Skip to content

Inplace dunders can return NotImplemented, and that's not documented #104219

Closed
@Gouvernathor

Description

@Gouvernathor

See this discussion.
Normal NotImplemented situation : A() + B() is resolved in A.__add__(A(), B()) which if returning NotImplemented, falls back to B.__radd__(B(), A()).
Now this behavior means there can be a double fallback : in a += b, if A.__iadd__ exists but returns NotImplemented, it will first fall back to A.__add__ and then to B.__radd__.
This is a great feature, but it's not currently documented.

Linked PRs

Metadata

Metadata

Assignees

No one assigned

    Labels

    docsDocumentation in the Doc dir

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions