class OriginalExampleObject(object):

    def __init__(self, name, nid):
        self.name = name
self.id = nid

def __repr__(self):
    return '(OriginalExampleObject [%s] [%s])' % (self.name, self.id)


class SetExampleObj(OriginalExampleObject):

    def __init__(self, name, nid):
        super(SetExampleObj, self).__init__(name, nid)

def __eq__(self, other):
    return self.id == other.id

def __hash__(self):
    return self.id.__hash__()
AObject = SetExampleObj('A', 1)
BObject = SetExampleObj('B', 1)
CObject = SetExampleObj('C', 2)
s = set()
s.add(AObject)
s.add(CObject)
print(s)
s.add(BObject)
print(s)
How to get unique list using a key word :Python