[Chicago] Ode to <>
Brian Ray
bray at sent.com
Fri Sep 1 17:40:23 CEST 2006
On Sep 1, 2006, at 10:22 AM, Ian Bicking wrote:
> You got __cmp__ wrong -- you probably meant to do __eq__; __cmp__ is a
> -1/0/1 sorting comparison. So 0 means equal (-1 means less-than, 1
> means more-than).
OK,
class A:
def __init__(self,title):
self.title = title
def __eq__(self,rhs):
if rhs.title == self.title:
return True
return False
if __name__ == "__main__":
mine = A("Hi")
your = A("Hi")
print mine == your
your.title = "Bye"
print mine == your
Nice.
More information about the Chicago
mailing list