You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
As discussed on the Python-Ideas mailing list, it is time to discourage the use of operator.__dunder__ functions. Not to remove them or deprecate them, just change the documentation to make it clear that the dunderless versions are preferred.
Guido +1'ed this suggestion, and there were no objections:
My suggestion from the python-ideas thread:: replace the current
"The function names are those used for special class methods; variants without leading and trailing __ are also provided for convenience."
with
""Many function names are those used for special methods, minus the double underscores. For backward compatibility, many of these have a variant with the double underscores kept. We recommend using the dunderless form. Note that operator.__add__(x, y), for instance, being the same as x + y, is not the same as x.__add__(y)."
Possibly add ", since the first two may result in calling y.__radd__(x)".
New changeset d38caf6 by Terry Jan Reedy (Miss Islington (bot)) in branch '3.6':
[3.6] bpo-30085: Improve documentation for operator (GH-1171) (bpo-3736) d38caf6
Activity
stevendaprano commentedon Apr 17, 2017
As discussed on the Python-Ideas mailing list, it is time to discourage the use of operator.__dunder__ functions. Not to remove them or deprecate them, just change the documentation to make it clear that the dunderless versions are preferred.
Guido +1'ed this suggestion, and there were no objections:
https://mail.python.org/pipermail/python-ideas/2017-April/045424.html
terryjreedy commentedon Apr 20, 2017
My suggestion from the python-ideas thread:: replace the current
"The function names are those used for special class methods; variants without leading and trailing __ are also provided for convenience."
with
""Many function names are those used for special methods, minus the double underscores. For backward compatibility, many of these have a variant with the double underscores kept. We recommend using the dunderless form. Note that operator.__add__(x, y), for instance, being the same as x + y, is not the same as x.__add__(y)."
Possibly add ", since the first two may result in calling y.__radd__(x)".
Raymond assigned the
terryjreedy commentedon Apr 20, 2017
Raymond assigned the PR to himself, so I added him here as nosy and assignee.
SanketDG commentedon Apr 21, 2017
@terry, I have updated the same, thanks!
terryjreedy commentedon Sep 14, 2017
Raymond, may someone else merge this? I will add a blurb.
terryjreedy commentedon Sep 24, 2017
New changeset 5b9299d by Terry Jan Reedy (Sanket Dasgupta) in branch 'master':
bpo-30085: Improve documentation for operator (bpo-1171)
5b9299d
terryjreedy commentedon Sep 24, 2017
New changeset d38caf6 by Terry Jan Reedy (Miss Islington (bot)) in branch '3.6':
[3.6] bpo-30085: Improve documentation for operator (GH-1171) (bpo-3736)
d38caf6