On Sat, May 17, 2008 at 2:18 PM, Tiago Katcipis <[EMAIL PROTECTED]> wrote: > Im writing a class on python and i want to implement the == and != operators > on it. I have read about __cmp__ and about __eq__ for == and __ne__ for ! =. > My question is... who is the better to use?
Use __cmp__() if it meets your needs - you just have to define one method and you get all comparisons. The other special methods - "rich comparisons" - were introduced in Python 2.1 to allow additional flexibility when __cmp__() is not adequate. http://www.amk.ca/python/2.1/index.html#SECTION000500000000000000000 Kent _______________________________________________ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor