Removing duplicates from a list

drochom drochom at googlemail.com
Thu Sep 15 16:28:08 CEST 2005


i suppose this one is faster (but in most cases efficiency doesn't
matter)

>>> def stable_unique(s):
	e = {}
	ret = []
	for x in s:
		if not e.has_key(x):
			e[x] = 1
			ret.append(x)
	return ret

cheers,
przemek




More information about the Python-list mailing list