[Tutor] Best way to define comparison

Kent Johnson kent37 at tds.net
Sun May 18 01:36:47 CEST 2008


On Sat, May 17, 2008 at 7:04 PM, Tiago Katcipis <katcipis at inf.ufsc.br> wrote:
> ive been reading and really seens to be better to use cmp... i will not have
> to write a method to every single operator. But when python compare
> objects...like in Sets or Lists...to check for membership etc, it uses cmp
> ou eq?

It uses __eq__() if it is defined, otherwise __cmp__()
http://docs.python.org/ref/customization.html

Kent

PS Please use Reply All to reply to the list


More information about the Tutor mailing list