On Thu, Apr 13, 2017 at 8:24 AM, Chris Warrick <kwpol...@gmail.com> wrote: > On 13 April 2017 at 09:43, eryk sun <eryk...@gmail.com> wrote: >> The functions in the operator module implement abstract behavior (e.g. >> PyNumber_Add in CPython): >> >> >>> operator.__add__(C(), D()) >> 42 > > Those functions also do not need underscores — operator.add is a > prettier way to achieve the same result.
I debated myself about which one to use in the example. The dunder aliases were added for completeness, to clarify the relationship to the corresponding special method, and I suppose to make it simpler to dynamically call them. I opted to use the explicit name, even though it's an alias because it seemed to make the example more consistent. Normally I would call operator.add. -- https://mail.python.org/mailman/listinfo/python-list