__cmp__ method

marek.rocki at wp.pl marek.rocki at wp.pl
Wed Jun 14 19:19:27 EDT 2006


Python documentation says:
>__cmp__( self, other)
> Called by comparison operations if rich comparison (see above) is not defined.
So it seems you have to redefine rich comparisons __lt__, __gt__,
__eq__ etc as well.

If all you need is change sorting order, why not use appropriate
parameters of sorted() function (cmp=... or key=...)?




More information about the Python-list mailing list