Rich comparison methods don't work in sets?
matt at tplus1.com
Fri Jun 19 21:26:03 CEST 2009
On Fri 19 Jun 2009 03:02:44 PM EDT, Gustavo Narea wrote:
> Hello, everyone.
> I've noticed that if I have a class with so-called "rich comparison"
> (__eq__, __ne__, etc.), when its instances are included in a set,
> set.__contains__/__eq__ won't call the .__eq__ method of the elements
> and thus
> the code below:
> obj1 = RichComparisonClass()
> obj2 = RichComparisonClass()
>>> obj1 is obj2
return? I don't know anything about set internals.
More information about the Python-list