Best way to make a list unique?

Eric Pederson whereU at now.com
Sun Mar 6 12:57:28 CET 2005


I have 

>>> listA=[1,2,3,4,5,4,3,4,3,2,1]

and I want a list of only the unique members.

This seems inefficient, but works fine over my small sample lists:

>>> listA=[a for a in set(listA)]


Is there a more efficient approach for cases where listA is large?






Eric Pederson
:::::::::::::::::::::::::::::::::::
domainNot="@something.com"
domainIs=domainNot.replace("s","z")
ePrefix="".join([chr(ord(x)+1) for x in "do"])
mailMeAt=ePrefix+domainIs
:::::::::::::::::::::::::::::::::::




More information about the Python-list mailing list