私のpython OrderedDictが「順不同」に初期化されるのはなぜですか?
ここでの解決策は、説明ほど興味深いものではありません。ここには私が得られない何かがあり、おそらく説明は私だけでなく他の人にも役立つでしょう.
>>> from collections import OrderedDict
>>> spam = OrderedDict(s = (1, 2), p = (3, 4), a = (5, 6), m = (7, 8))
>>> spam
OrderedDict([('a', (5, 6)), ('p', (3, 4)), ('s', (1, 2)), ('m', (7, 8))])
>>> for key in spam.keys():
... print key
...
# this is 'ordered' but not the order I wanted....
a
p
s
m
# I was expecting (and wanting):
s
p
a
m