remove duplicates from list *preserving order*
wittempj at hotmail.com
wittempj at hotmail.com
Thu Feb 3 16:08:00 EST 2005
You could do it with a class, like this, I guess it is a bit faster
than option 1, although I'm no connaisseur of python internals.....
-class uniquelist(list):
- def __init__(self, l):
- for item in l:
- self.append(item)
- def append(self, item):
- if item not in self:
- list.append(self, item)
-l = [1, 1, 2, 3, 3, 4]
-print l
-m = uniquelist(l)
-print m
More information about the Python-list
mailing list