Possible Duplicate:
How do you remove duplicates from a list in Python whilst preserving order?
Does Python have an ordered set?
I find myself doing the following quite frequently:
list_of_items # I have a list of items
set(list_of_items) # I want to remove duplicates
However, in converting to a set
, I lose the initial ordering I had in the list, which is important.
What is the best way to remove duplicates in a list AND keep the initial (relative) ordering of the list?