-
-
Notifications
You must be signed in to change notification settings - Fork 32k
doc: Mention the missing reflected operations #119931
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
doc: Mention the missing reflected operations #119931
Conversation
To maintain consistency with other arithmetic operations.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
Co-authored-by: Mark Dickinson <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is also the same issue for __rpow__
, __rtruediv__
, __rfloordiv__
, __rmod__
, __rlshift__
, __rrshift__
, and maybe others.
It is better to fix them all in a single PR.
Alternatively, we can remove references to __radd__
and __rmul__
.
A Python core developer has requested some changes be made to your pull request before we can consider merging it. If you could please address their requests along with any other requests in other reviews from core developers that would be appreciated. Once you have made the requested changes, please leave a comment on this pull request containing the phrase |
Add links to `__rpow__`, `__rtruediv__`, `__rfloordiv__`, `__rmod__`, `__rlshift__` and `__rrshift__`.
__rsub__
arithmetic operation
Note that |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For divisions and shifts, I think that it is better to be explicit what dunder customizes what operator.
While we are here, I think it is worth to document also the dunders for the @
operator.
As per review request, improved shifting operators wording and added `@` operators. 👍
Hope I covered both things as intended. 👍 |
Doc/reference/expressions.rst
Outdated
@@ -1314,8 +1318,9 @@ 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. | |||
This operation can be customized using the special :meth:`~object.__truediv__`, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There are two different operations.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There are two different operations.
Nice catch, I was forgetting this one. 👍
Doc/reference/expressions.rst
Outdated
:meth:`~object.__rshift__` methods. | ||
The left shift operation can be customized using the special :meth:`~object.__lshift__` | ||
and :meth:`~object.__rlshift__` methods. | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would not be better to merge these two paragraphs?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For sure, merged it and did the same formatting for division and floor division operations. 👍
Separates division and floor division and remove spacing from shifting operations.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM.
Thank you for your contribution @paulofreitas.
Thanks @paulofreitas for the PR, and @serhiy-storchaka for merging it 🌮🎉.. I'm working now to backport this PR to: 3.12, 3.13. |
…rations (pythonGH-119931) (cherry picked from commit bf5e106) Co-authored-by: Paulo Freitas <[email protected]>
GH-120063 is a backport of this pull request to the 3.13 branch. |
…rations (pythonGH-119931) (cherry picked from commit bf5e106) Co-authored-by: Paulo Freitas <[email protected]>
GH-120064 is a backport of this pull request to the 3.12 branch. |
Thank you for all your help reviewing! Glad to contribute here, looking forward to contribute more! 🎉 🐍 |
Looking forward to review more your PRs. |
…ary operations (GH-119931) (#120063) doc: Mention the missing reflected special methods for all binary operations (GH-119931) (cherry picked from commit bf5e106) Co-authored-by: Paulo Freitas <[email protected]>
…ary operations (GH-119931) (#120064) doc: Mention the missing reflected special methods for all binary operations (GH-119931) (cherry picked from commit bf5e106) Co-authored-by: Paulo Freitas <[email protected]>
Just a minor doc update to maintain consistency with other reflected operations documented in
reference/expressions
. 👍📚 Documentation preview 📚: https://cpython-previews--119931.org.readthedocs.build/