The meaning is the same, but the implementation is different. Lists just check every object, checking for equality, so it works for your class. Sets hash objects first, and if they do not implement the hash properly, the set looks inoperative.
Your class defines __eq__ , but does not define __hash__ , and therefore will not work properly for collections or as dictionary keys. The rule for __eq__ and __hash__ is that two objects that __eq__ as True should also have equal hashes. By default, a hash of objects based on their memory address. Thus, your two objects, equal to your definition, do not provide the same hash, so they violate the __eq__ and __hash__ .
If you provide an __hash__ implementation, it will work fine. For your sample code, this could be:
def __hash__(self): return hash(self.someattribute)
Ned batchelder
source share