Steve,

Yeah, in this particular application the ordering and reoccurrence of a value in a non-contiguous way does matter; if those two things weren't required I think the method you suggested would be a good way to remove the duplicates.

Thanks!

Coates, Steve (ACHE) wrote:
It's not _exactly_ what you asked for but it may be enough...

Python 2.4 (#60, Nov 30 2004, 11:49:19) [MSC v.1310 32 bit (Intel)] on
win32
Type "help", "copyright", "credits" or "license" for more information.

from sets import Set
l = [0,0,1,1,1,2,2,3,3,3,2,2,2,4,4,4,5]
s = Set(l)
s

Set([0, 1, 2, 3, 4, 5])

l2 = list(s)
l2

[0, 1, 2, 3, 4, 5]


I say it's not exactly what you wanted because I don't think the ordering of l2 is necessarily the same as l. That may or may not be a problem for you.

Regards
Steve
--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to