operator.__cmp__

Antoon Pardon apardon at forel.vub.ac.be
Wed Dec 4 04:54:48 EST 2002


In artikel <3DED0D8F.969DDF1D at alcyone.com> schreef Erik Max Francis:
> Antoon Pardon wrote:
> 
>> I have written a few modules in which something like the
>> above would be usefull? So I wonder why are the comparisons
>> not included in the operator module?
> 
> The operator module is for cousins of operators that are in the form of
> functions.  Since cmp is already a function and is not an operator,
> there's no need for its presence in the the operator module.
> 
> Under what circumstances would you have thought that an operator.cmp
> would have been preferable to cmp itself?
> 

I'm blushing up to my ears now. I just missed it. Because the name of
the functions in operator is the same as the name of the associated methods
for implementing these operators and __cmp__ is an associated method
for implementing the comparisons I thought the operator module is the
place to look for what I need.

I still find it a bit inconsistent to have 'cmp' as a builtin and
'add' as a function from a module while 'lt' is completly missing.
I think it would have been better if all associated methods for
implemeting operators had cousin functions that could be found
in one single place.

-- 
Antoon Pardon



More information about the Python-list mailing list