The od package adds a shorthand syntax to create instances of OrderedDict
>>> import od
>>>
>>> od["cat": "fish", "mouse": "cheese"]
OrderedDict([('cat', 'fish'), ('mouse', 'cheese')])
>>> od["mouse": "cheese", "cat": "fish"]
OrderedDict([('mouse', 'cheese'), ('cat', 'fish')])
You can also use it like the regular constructor for OrderedDict:
>>> od()
OrderedDict()
>>> an_iterable = [("cat", "fish"), ("mouse", "cheese")]
>>> od(an_iterable)
OrderedDict([('cat', 'fish'), ('mouse', 'cheese')])
Install this package using pip:
$ pip install --user od