[Python-3000] Total ordering and __cmp__
Terry Reedy
tjreedy at udel.edu
Wed Mar 21 03:40:56 CET 2007
"Collin Winter" <collinw at gmail.com> wrote in message
news:43aa6ff70703201810p9d731b8v3497a48539d5dc84 at mail.gmail.com...
| Quoting from the commit message for r51533, which removed the default
ordering:
|
| What's the status on this? FWIW, I would like to see __cmp__ stay as a
| fallback measure if __eq__, __ne__, __lt__, etc aren't defined for
| total ordering purposes. I've run across this while trying to get the
| docs toolchain working, and I was initially shocked that __cmp__ was
| no longer called.
An alternative would be to give the object class comparison methods defined
in terms of a missing __cmp() method.
def __eq__(self,other): return __cmp(self,other) == 0 # etc
This would put the fallback to and conversion of cmp -1,0,1 output in *one*
place instead of sprinkled everywhere. Or these could go into a cmp_order
mixin put in some lib module.
Terry Jan Reedy
More information about the Python-3000
mailing list