On Fri, 2009-03-20 at 07:16 -0700, Alexzive wrote: > Hello there, > > I'd like to get the same result of set() but getting an indexable > object. > How to get this in an efficient way? > > Example using set > > A = [1, 2, 2 ,2 , 3 ,4] > B= set(A) > B = ([1, 2, 3, 4]) > > B[2] > TypeError: unindexable object
>>> A = [1, 2, 2 ,2 , 3, 4] >>> B = list(set(A)) >>> B[2] 3 However, as sets are unordered, there is no guarantee that B will have the same ordering as A. -- http://mail.python.org/mailman/listinfo/python-list