Eliminating duplicates entries from a list efficiently

Duncan Booth me at privacy.net
Sat Jul 3 15:15:58 CEST 2004

Roy Smith <roy at panix.com> wrote in news:roy-
395979.20555402072004 at reader2.panix.com:

> Something like:
> d = {}
> for item in list:
>    d[item] = True
> list = d.keys()

Or just:

   aList = dict.fromkeys(aList).keys()

which does the same thing (except I renamed the variable to avoid confusion 
with the list type).

More information about the Python-list mailing list