I have a multiple instances of a class. I consider two classes equal, when a certain attribute matches.
All instances are in an array
list = [a, b, c]
d in list
class Foo: def __init__(self, x): self.x = x def __eq__(self, other): if isinstance(other, Foo): return self.x == other.x a = [1,2,3,Foo(4),Foo(5)] Foo(5) in a >>>True Foo(3) in a >>>False