Would there be support for a more general cmp/__cmp__
Duncan Booth
duncan.booth at invalid.invalid
Thu Oct 20 05:21:46 EDT 2005
More information about the Python-list mailing list
Thu Oct 20 05:21:46 EDT 2005
- Previous message (by thread): Would there be support for a more general cmp/__cmp__
- Next message (by thread): Would there be support for a more general cmp/__cmp__
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Antoon Pardon wrote: > Op 2005-10-20, Duncan Booth schreef <duncan.booth at invalid.invalid>: >> Antoon Pardon wrote: >> >>> The problem now is that the cmp protocol has no way to >>> indicate two objects are incomparable, they are not >>> equal but neither is one less or greater than the other. >> >> If that is the case then you implement __eq__ and __ne__ to return >> True/False and make cmp throw an exception. I don't see any need to >> extend the cmp protocol. > > That is not sufficient. There are domains where an order exists, but > not a total order. So for some couples of elements it is possible to > say one is less than the other, but not for all such couples. > > Your solution wouldn't allow for such a case. > I don't see why not. If an ordering exists then __cmp__ returns a result otherwise it throws an exception. So long as you define __eq__ and __ne__, __cmp__ is never called when checking for equality.
- Previous message (by thread): Would there be support for a more general cmp/__cmp__
- Next message (by thread): Would there be support for a more general cmp/__cmp__
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-list mailing list