class Test(object):

    def __init__(self, attr1, attr2):
        self.attr1 = attr1
self.attr2 = attr2

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

def __eq__(self, other):
    pass
Compare object instances for equality by their attributes in Python