cmp and sorting non-symmetric types
Raymond Hettinger
python at rcn.com
Wed Nov 14 16:21:38 EST 2007
On Nov 13, 2:54 pm, Paul Rubin <http://phr...@NOSPAM.invalid> wrote:
> Carl Banks <pavlovevide... at gmail.com>
>
> > resurrecting the __cmp__ operator.
>
> I didnd't realize __cmp__ was going. Are we really supposed to
> implement all the rich comparison methods to code an ordered class?
> Or is there some kind of library superclass we can inherit from that
> implements something like __cmp__? What about making __key__ ?
IIRC, you need only define __le__ and __eq__ and the rest get defined
using a mixin class.
Raymond
More information about the Python-list
mailing list