Trouble with max() and __cmp__()
Gabriel Genellina
gagsl-py at yahoo.com.ar
Sun Jan 28 21:15:44 EST 2007
At Sunday 28/1/2007 18:21, Thomas Nelson wrote:
><wojciech_m... at poczta.null.onet.pl.invalid> wrote:
> >Define method __gt__.
>
>This works, thanks. I was a little surprised though. is __cmp__ used
>by any builtin functions?
The problem is, rich comparison functions take precedence over
__cmp__, so if your base class (list in this case) already defines
rich comparison, you have to redefine them all.
For simple cases, you can just redefine __cmp__ and reimplement all
others __gt__, __lt__ etc using it.
--
Gabriel Genellina
Softlab SRL
__________________________________________________
Preguntá. Respondé. Descubrí.
Todo lo que querías saber, y lo que ni imaginabas,
está en Yahoo! Respuestas (Beta).
¡Probalo ya!
http://www.yahoo.com.ar/respuestas
More information about the Python-list
mailing list