def __str__(self):
    return str(self.__dict__)

def __eq__(self, other):
    return self.__dict__ == other.__dict__
t1 = Test('foo', 42)
t2 = Test('foo', 42)
t3 = Test('bar', 42)
print(t1, t2, t3)
print(t1 == t2)
print(t2 == t3)
Compare object instances for equality by their attributes in Python