.. image:: https://img.shields.io/pypi/v/easydict.svg
:target: https://pypi.python.org/pypi/easydict
.. image:: https://img.shields.io/pypi/dm/easydict.svg
:target: https://pypi.python.org/pypi/easydict
========
Easydict
========
*EasyDict* allows to access dict values as attributes (works recursively).
A Javascript-like properties dot notation for python dicts.
INSTALL
=======
::
pip install easydict
USAGE
=====
::
>>> from easydict import EasyDict as edict
>>> d = edict({'foo':3, 'bar':{'x':1, 'y':2}})
>>> d.foo
3
>>> d.bar.x
1
>>> d = edict(foo=3)
>>> d.foo
3
Very useful when exploiting parsed JSON content !
::
>>> from easydict import EasyDict as edict
>>> from simplejson import loads
>>> j = """{
"Buffer": 12,
"List1": [
{"type" : "point", "coordinates" : [100.1,54.9] },
{"type" : "point", "coordinates" : [109.4,65.1] },
{"type" : "point", "coordinates" : [115.2,80.2] },
{"type" : "point", "coordinates" : [150.9,97.8] }
]
}"""
>>> d = edict(loads(j))
>>> d.Buffer
12
>>> d.List1[0].coordinates[1]
54.9
Can set attributes as easily as getting them :
::
>>> d = EasyDict()
>>> d.foo = 3
>>> d.foo
3
It is still a ``dict`` !
::
>>> d = EasyDict(log=False)
>>> d.debug = True
>>> d.items()
[('debug', True), ('log', False)]
Instance and class attributes are accessed like usual objects...
::
>>> class Flower(EasyDict):
... power = 1
...
>>> f = Flower({'height': 12})
>>> f.power
1
>>> f['power']
1
LICENSE
=======
* Lesser GNU Public License
AUTHORS
=======
* Mathieu Leplatre <mathieu.leplatre@makina-corpus.com>
|makinacom|_
.. |makinacom| image:: http://depot.makina-corpus.org/public/logo.gif
.. _makinacom: http://www.makina-corpus.com
Similar tools
=============
* `TreeDict <http://pypi.python.org/pypi/treedict>`_, a fast and full-featured dict-like tree container.
* `addict <https://github.com/mewwts/addict>`_
=========
CHANGELOG
=========
1.11 (2023-10-24)
=================
- Fix #39: RecursionError when dict in class member (#41)
- Minor changes in README
1.10 (2022-09-28)
=================
* Make tests compatible with python2 and python3 (thanks @JackLangerman)
* Dictify input
* Fix license metadata
1.9 (2018-10-18)
================
* Fix issue #3 that update and pop now work correctly on EasyDicts.
1.8 (2018-08-17)
================
* Update package classifiers.
1.7 (2017-04-27)
================
* Prevent copying sub-EasyDicts on assignment to fix unpickling (#7, thanks @Chronos-Sk)
1.6 (2015-01-27)
================
* Allow setting attributes via setting items (thanks phivos)
1.5 (2014-08-07)
================
* Allow subclassing using self instead of class name (thanks Steve Engledow)
1.4 (2011-03-13)
================
* Access class attributes like instance attributes
1.3 (2012-02-08)
================
* Better documentation and tests
1.2 (2011-06-08)
================
* Fix inclusion of README
1.1 (2012-04-21)
================
* Switch to distutils2
1.0 (2011-04-18)
================
* Initial working version
Raw data
{
"_id": null,
"home_page": "https://github.com/makinacorpus/easydict",
"name": "easydict",
"maintainer": "",
"docs_url": null,
"requires_python": "",
"maintainer_email": "",
"keywords": "Tools",
"author": "Mathieu Leplatre",
"author_email": "mathieu.leplatre@makina-corpus.com",
"download_url": "https://files.pythonhosted.org/packages/0a/d2/deb3296d08097fedd622d423c0ec8b68b78c1704b3f1545326f6ce05c75c/easydict-1.11.tar.gz",
"platform": null,
"description": ".. image:: https://img.shields.io/pypi/v/easydict.svg\n :target: https://pypi.python.org/pypi/easydict\n\n.. image:: https://img.shields.io/pypi/dm/easydict.svg\n :target: https://pypi.python.org/pypi/easydict\n\n========\nEasydict\n========\n\n*EasyDict* allows to access dict values as attributes (works recursively). \nA Javascript-like properties dot notation for python dicts.\n\nINSTALL\n=======\n\n::\n \n pip install easydict\n\n\nUSAGE\n=====\n\n::\n\n >>> from easydict import EasyDict as edict\n >>> d = edict({'foo':3, 'bar':{'x':1, 'y':2}})\n >>> d.foo\n 3\n >>> d.bar.x\n 1\n \n >>> d = edict(foo=3)\n >>> d.foo\n 3\n\n\nVery useful when exploiting parsed JSON content ! \n\n::\n\n >>> from easydict import EasyDict as edict\n >>> from simplejson import loads\n >>> j = \"\"\"{\n \"Buffer\": 12,\n \"List1\": [\n {\"type\" : \"point\", \"coordinates\" : [100.1,54.9] },\n {\"type\" : \"point\", \"coordinates\" : [109.4,65.1] },\n {\"type\" : \"point\", \"coordinates\" : [115.2,80.2] },\n {\"type\" : \"point\", \"coordinates\" : [150.9,97.8] }\n ]\n }\"\"\"\n >>> d = edict(loads(j))\n >>> d.Buffer\n 12\n >>> d.List1[0].coordinates[1]\n 54.9\n\nCan set attributes as easily as getting them :\n\n::\n\n >>> d = EasyDict()\n >>> d.foo = 3\n >>> d.foo\n 3\n\nIt is still a ``dict`` !\n\n::\n\n >>> d = EasyDict(log=False)\n >>> d.debug = True\n >>> d.items()\n [('debug', True), ('log', False)]\n\nInstance and class attributes are accessed like usual objects...\n\n::\n\n >>> class Flower(EasyDict):\n ... power = 1\n ...\n >>> f = Flower({'height': 12})\n >>> f.power\n 1\n >>> f['power']\n 1\n\nLICENSE\n=======\n\n* Lesser GNU Public License\n\nAUTHORS\n=======\n\n* Mathieu Leplatre <mathieu.leplatre@makina-corpus.com>\n\n|makinacom|_\n\n.. |makinacom| image:: http://depot.makina-corpus.org/public/logo.gif\n.. _makinacom: http://www.makina-corpus.com\n\nSimilar tools\n=============\n\n* `TreeDict <http://pypi.python.org/pypi/treedict>`_, a fast and full-featured dict-like tree container.\n* `addict <https://github.com/mewwts/addict>`_\n\n\n=========\nCHANGELOG\n=========\n\n1.11 (2023-10-24)\n=================\n\n- Fix #39: RecursionError when dict in class member (#41)\n- Minor changes in README\n\n1.10 (2022-09-28)\n=================\n\n* Make tests compatible with python2 and python3 (thanks @JackLangerman)\n* Dictify input\n* Fix license metadata \n\n1.9 (2018-10-18)\n================\n\n* Fix issue #3 that update and pop now work correctly on EasyDicts.\n\n\n1.8 (2018-08-17)\n================\n\n* Update package classifiers.\n\n\n1.7 (2017-04-27)\n================\n\n* Prevent copying sub-EasyDicts on assignment to fix unpickling (#7, thanks @Chronos-Sk)\n\n1.6 (2015-01-27)\n================\n\n* Allow setting attributes via setting items (thanks phivos)\n\n1.5 (2014-08-07)\n================\n\n* Allow subclassing using self instead of class name (thanks Steve Engledow)\n\n1.4 (2011-03-13)\n================\n\n* Access class attributes like instance attributes\n\n1.3 (2012-02-08)\n================\n\n* Better documentation and tests\n\n1.2 (2011-06-08)\n================\n\n* Fix inclusion of README\n\n1.1 (2012-04-21)\n================\n\n* Switch to distutils2\n\n1.0 (2011-04-18)\n================\n\n* Initial working version\n",
"bugtrack_url": null,
"license": "LGPL-3.0",
"summary": "Access dict values as attributes (works recursively).",
"version": "1.11",
"project_urls": {
"Download": "http://pypi.python.org/pypi/easydict/",
"Homepage": "https://github.com/makinacorpus/easydict"
},
"split_keywords": [
"tools"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "0ad2deb3296d08097fedd622d423c0ec8b68b78c1704b3f1545326f6ce05c75c",
"md5": "d5d165b5c4a17146c5636161618bce5c",
"sha256": "dcb1d2ed28eb300c8e46cd371340373abc62f7c14d6dea74fdfc6f1069061c78"
},
"downloads": -1,
"filename": "easydict-1.11.tar.gz",
"has_sig": false,
"md5_digest": "d5d165b5c4a17146c5636161618bce5c",
"packagetype": "sdist",
"python_version": "source",
"requires_python": null,
"size": 6644,
"upload_time": "2023-10-23T23:01:37",
"upload_time_iso_8601": "2023-10-23T23:01:37.686782Z",
"url": "https://files.pythonhosted.org/packages/0a/d2/deb3296d08097fedd622d423c0ec8b68b78c1704b3f1545326f6ce05c75c/easydict-1.11.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2023-10-23 23:01:37",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "makinacorpus",
"github_project": "easydict",
"travis_ci": true,
"coveralls": false,
"github_actions": false,
"lcname": "easydict"
}