Customizing sequence types

Gabriel Genellina gagsl-py2 at
Tue Nov 18 01:19:24 CET 2008

En Mon, 17 Nov 2008 16:21:39 -0200, Chris Rebert <clp at>  

> __cmp__ does rich comparisons and is supposed to return 0 for
> equality, -1 if the object is less than the other, and 1 if it's
> greater than the other. So, using == as its definition is broken as it

Just a little correction: __cmp__ is the "old" comparison method, the  
"rich" comparisons are the six __eq__, __lt__, __gt__, ...
(__cmp__ assumes that any object is either equal, or greater, or less than  
another, and no other possibility exists; this isn't true for many  
objects, that's why the "rich" methods had to be introduced).

Gabriel Genellina

More information about the Python-list mailing list