classification
Title: Discourage operator.__dunder__ functions
Type: Stage:
Components: Documentation Versions:
process
Status: open Resolution:
Dependencies: Superseder:
Assigned To: rhettinger Nosy List: docs@python, ncoghlan, rhettinger, sanketdg, steven.daprano, terry.reedy
Priority: normal Keywords:

Created on 2017-04-17 02:27 by steven.daprano, last changed 2017-04-21 16:28 by sanketdg.

Pull Requests
URL Status Linked Edit
PR 1171 open sanketdg, 2017-04-18 19:45
Messages (4)
msg291774 - (view) Author: Steven D'Aprano (steven.daprano) * (Python committer) Date: 2017-04-17 02:27
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
msg291991 - (view) Author: Terry J. Reedy (terry.reedy) * (Python committer) Date: 2017-04-20 18:33
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
msg291993 - (view) Author: Terry J. Reedy (terry.reedy) * (Python committer) Date: 2017-04-20 18:48
Raymond assigned the PR to himself, so I added him here as nosy and assignee.
msg292062 - (view) Author: Sanket Dasgupta (sanketdg) * Date: 2017-04-21 16:28
@terry, I have updated the same, thanks!
History
Date User Action Args
2017-04-21 16:28:48sanketdgsetnosy: + sanketdg
messages: + msg292062
2017-04-20 18:48:47terry.reedysetmessages: + msg291993
2017-04-20 18:33:57terry.reedysetassignee: docs@python -> rhettinger

messages: + msg291991
nosy: + rhettinger
2017-04-18 19:45:51sanketdgsetpull_requests: + pull_request1301
2017-04-17 02:27:09steven.dapranocreate