I use Python dictionary:
>>> a = {}
>>> a[\"w\"] = {}
>>> a[\"a\"] = {}
>>> a[\"s\"] = {}
>>> a
{\'a\': {}, \'s\
you should use OrderedDict
instead of Dict
.
http://docs.python.org/2/library/collections.html
http://docs.python.org/2/library/collections.html#collections.OrderedDict
An OrderedDict is a dict that remembers the order that keys were first inserted. If a new entry overwrites an existing entry, the original insertion position is left unchanged. Deleting an entry and reinserting it will move it to the end.
>>> import collections
>>> a = collections.OrderedDict()
>>> a['w'] = {}
>>> a['a'] = {}
>>> a['s'] = {}
>>> a
OrderedDict([('w', {}), ('a', {}), ('s', {})])
>>> dict(a)
{'a': {}, 's': {}, 'w': {}}