class MyClass(object):

    def __init__(self, classId, tag):
        self.classId = classId
self.tag = tag
myList = [MyClass(1, 'ABC'), MyClass(2, 'DEF'), MyClass(3, 'DEF')]
uniqList = list({x.tag: x for x in myList}.values())
print([x.classId for x in uniqList])
How to make a list in Python distinct based on a property of the class in the list?