operator module functions

Ethan Furman ethan at stoneleaf.us
Wed Oct 8 21:38:22 CEST 2014


On 10/08/2014 12:09 PM, Terry Reedy wrote:
> On 10/8/2014 6:57 AM, Steven D'Aprano wrote:
>
>> According to the documentation, operator.__add__ is the "official" function,
>> and operator.add is just there for convenience.
>
> You are paraphrasing "The function names are those used for special class methods; variants without leading and trailing
> __ are also provided for convenience."  But then there is the following:
>
> 10.3.1. Mapping Operators to Functions
>
> This table shows how abstract operations correspond to operator symbols in the Python syntax and the functions in the
> operator module.
> Operation     Syntax     Function
> Addition     a + b     add(a, b)
>
> etc, using the 'convenient' names. I would like to deprecate and eventually remove the dunder names.  To me, the
> duplication is not 'convenient'.

LOL, no kidding!  The main reason I bother using the operator module is for the readability of not seeing the dunders, 
and the writability of not having to type them.

--
~Ethan~



More information about the Python-list mailing list