File: PKG-INFO

package info (click to toggle)
easydict 1.13-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 124 kB
  • sloc: python: 62; makefile: 3
file content (210 lines) | stat: -rw-r--r-- 4,188 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
Metadata-Version: 2.1
Name: easydict
Version: 1.13
Summary: Access dict values as attributes (works recursively).
Home-page: https://github.com/makinacorpus/easydict
Download-URL: http://pypi.python.org/pypi/easydict/
Author: Mathieu Leplatre
Author-email: mathieu.leplatre@makina-corpus.com
License: LGPL-3.0
Keywords: Tools
Classifier: Topic :: Utilities
Classifier: Natural Language :: English
Classifier: Operating System :: OS Independent
Classifier: Intended Audience :: Developers
Classifier: Development Status :: 5 - Production/Stable
Classifier: License :: OSI Approved :: GNU Lesser General Public License v3 (LGPLv3)
Classifier: Programming Language :: Python :: 2.5
Classifier: Programming Language :: Python :: 3.6
License-File: LICENSE

.. 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.12 (2024-03-04)
=================

- Fix #46: Fix handling of optional default value for .pop() (#47)

1.12 (2024-02-13)
=================

- Fix #22: Do not convert tuple attributes to list (#44)

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