Remove duplicates in a sequence?

Robert Roy rjroy at takingcontrol.com
Thu Feb 10 23:34:00 EST 2000


There is a recent thread on this subject. If I recall, what seemed
fastest was 
mydict={}
for item in mylist:
	mydict[item]=None
mylist = mydict.keys()

If you care about relative order then it gets a bit more complicated'

On Fri, 11 Feb 2000 02:45:38 GMT, danielt3 at gte.net (Daniel T.) wrote:

>I have a sequence that contains strings, and I want to remove any
>duplicates. I know how to write a function to do it, but I was wondering
>if there was already one in the language or a library that does it.
>
>I've looked in the docs for "unique" and "remove" but no luck... Can
>anyone help me?
>
>-- 
>When a thing ceases to be a subject of controversy,
>it ceases to be a subject of interest.
>                                                   -- William Hazlitt




More information about the Python-list mailing list