[Tutor] ***SPAM*** List to dictionary
Luke Paireepinart
rabidpoobear at gmail.com
Thu Dec 7 06:53:44 CET 2006
>> I have a list of names (Names[]) and want to remove duplicate names in
>> the list. [snip]
>>
>
> The way I usually do this is something like:
>
> outDict = dict(map(lambda x: (x, 1), inList))
> names = outDict.keys()
> names.sort()
>
How about this :D
# Remove duplicates from a list:
>>> L = [1,2,2,3,3,3]
>>> [x for x in L if x not in locals()['_[1]'].__self__]
[1,2,3]
[accessed at
http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/204297 ]
Also, why is there now a ******SPAM***** in the subject heading?
Wonderingly,
-Luke
More information about the Tutor
mailing list