It's easy really,
>>> a=[4,2,6,5,3,6,4,2]
>>>
>>> a
[4, 2, 6, 5, 3, 6, 4, 2]
>>> list(set(a))
[2, 3, 4, 5, 6]
>>>
It works with lists of non-numerical values too:
>>> a=[(0,0),(2,3),(0,0),(3,2)]
>>> a
[(0, 0), (2, 3), (0, 0), (3, 2)]
>>> list(set(a))
[(3, 2), (0, 0), (2, 3)]
It doesn't work so well with classes:
>>> class Test(object):
... def __init__(self, v):
... self.value = v
... def __repr__(self):
... return "Test(%s)" % (self.value,)
...
>>> Test(20)
Test(20)
>>> a=[Test(2), Test(4), Test(5), Test(2), Test(3)]
>>> a
[Test(2), Test(4), Test(5), Test(2), Test(3)]
>>> list(set(a))
[Test(2), Test(4), Test(3), Test(5), Test(2)]
>>>
Creating the set doesn't remove the "duplicate" values, because it tests by 'id', which will be different even if all the attributes are the same. Defining a __eq__() or __cmp__() function doesn't seem to make a difference, either.