Based on Sven's answer, I found that I used collections. This way helped me accomplish what you want and let me add more elements to the dict:
import collections x=[1,2,20,6,210] z=collections.OrderedDict.fromkeys(x) z OrderedDict([(1, None), (2, None), (20, None), (6, None), (210, None)])
If you want to add elements, but still treat them as a set, which you can simply do:
z['nextitem']=None
And you can perform an operation like z.keys () on a dict and get a set:
z.keys() [1, 2, 20, 6, 210]
jimh Jan 30 '15 at 19:43 2015-01-30 19:43
source share