Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/ajtowns/odictliteral
https://github.com/ajtowns/odictliteral
Last synced: 11 days ago
JSON representation
- Host: GitHub
- URL: https://github.com/ajtowns/odictliteral
- Owner: ajtowns
- License: other
- Created: 2014-04-05T15:44:53.000Z (over 10 years ago)
- Default Branch: master
- Last Pushed: 2015-05-09T15:36:33.000Z (over 9 years ago)
- Last Synced: 2024-09-15T08:57:02.749Z (about 2 months ago)
- Language: Python
- Size: 237 KB
- Stars: 28
- Watchers: 3
- Forks: 5
- Open Issues: 1
-
Metadata Files:
- Readme: README.rst
- License: LICENSE
Awesome Lists containing this project
README
from odictliteral import odict
==============================Provides a nice way of specifying ordered dictionaries from Python source.
Example:
>>> from odictliteral import odict
>>> x = odict[1:2,3:4]
>>> print(x)
odict[1: 2, 3: 4]You can use odict as a replacement for OrderedDict otherwise, eg:
>>> y = odict( [(1,2), (3,4)] )
>>> print(y)
odict[1: 2, 3: 4]
>>> x == y
TrueYou should also be able to use odict in combination with OrderedDicts:
>>> z = OrderedDict( [(1,2), (3,4)] )
>>> print(z)
OrderedDict([(1, 2), (3, 4)])
>>> y == z
TrueThat's pretty much all there is to it. Should be compatible with Python
2.7 and Python 3; requires the "ordereddict" module to work with Python
2.4, 2.5 or 2.6.