[Tutor] Best way to define comparison

Tiago Katcipis katcipis at inf.ufsc.br
Sun May 18 04:29:58 CEST 2008


ops im sorry..i didnt noticed that reply just replyed to you..i thought it
would go to the list.

Thanks for the help

best regards

On Sat, May 17, 2008 at 8:36 PM, Kent Johnson <kent37 at tds.net> wrote:

> 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
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20080517/beffa79e/attachment.htm>


More information about the Tutor mailing list