Calling dunder methods manually

Chris Warrick kwpolska at gmail.com
Thu Apr 13 04:24:24 EDT 2017


On 13 April 2017 at 09:43, eryk sun <eryksun at 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.

-- 
Chris Warrick <https://chriswarrick.com/>
PGP: 5EAAEA16


More information about the Python-list mailing list