by tef__ · 16y ago · 0 comments
i.e you write 4+2 to add things not 4.add(2)
>>> class Foo:
... def __init__(self, name):
... self.name=name
>>> a1 = Foo('Alice')
>>> a2 = Foo('Alice')
>>> a1==a2
False
>>> Foo.__eq__ = lambda self,other: self.name==other.name
>>> a1==a2
True