Gustavo Narea wrote:

> I've noticed that if I have a class with so-called "rich comparison"
> methods
> (__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()

How is RichComparisonClass implemented? Did you provide a __hash__() method 
such that obj1 == obj2 implies hash(obj1) == hash(obj2)? This is necessary 
for instances of the class to work properly with sets and dicts.

Peter

-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to