Customizing sequence types

Gabriel Genellina gagsl-py2 at yahoo.com.ar
Mon Nov 17 19:19:24 EST 2008


En Mon, 17 Nov 2008 16:21:39 -0200, Chris Rebert <clp at rebertia.com>  
escribió:

> __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