A dictionary object with attributes support.
Project description
AttributeDict

A dictionary object with attributes support.
Install
Install using pip:
$ pip install attributedict
Use
Example:
from attributedict.collections import AttributeDict
data = AttributeDict({'foo': {'bar': [1, 2, 3]}})
data.foo # => `{'bar': [1, 2, 3]}}`
data.foo.bar # => `[1, 2, 3]`
data.foo = {'baz': True}
data.foo = # => `{'baz': True}`
del data.foo.baz
# and/or...
data = AttributeDict({'foo': {'bar': [1, 2, 3]}})
data['foo'] # => `{'bar': [1, 2, 3]}}`
data['foo']['bar'] # => `[1, 2, 3]`
data['foo'] = {'baz': True}
data['foo'] = # => `{'baz': True}`
del data['foo']['baz']
# instance of `dict`...
isinstance(data, dict) # => True
isinstance(data, attributedict.collections.AttributeDict) # => True
isinstance(data.__dict__, dict) # => True
isinstance(data.__dict__, attributedict.collections.AttributeDict) # => False
# no need for custom encoders...
data = AttributeDict({'foo': {'bar': [1, 2, 3]}})
json.dumps(data) # => `{"foo": {"bar": [1, 2, 3]}}`
json.dumps(data.__dict__) # => `{"foo": {"bar": [1, 2, 3]}}`
# etc.
Test
Clone down source code and run:
$ make install
$ make test
License
Released under the MIT license.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
attributedict-0.1.6.tar.gz
(8.4 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file attributedict-0.1.6.tar.gz.
File metadata
- Download URL: attributedict-0.1.6.tar.gz
- Upload date:
- Size: 8.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e2d1df574a10d146d4f66df3b1d9f9a71340b51c1ec9391e72de0bce560c21f1
|
|
| MD5 |
9c43b96ed05724cbbbbdb853913c3743
|
|
| BLAKE2b-256 |
96e886eb1fa92496af9556f730df8443fbd20e260a402b46c47fa8799d8ebc4e
|
File details
Details for the file attributedict-0.1.6-py2-none-any.whl.
File metadata
- Download URL: attributedict-0.1.6-py2-none-any.whl
- Upload date:
- Size: 9.8 kB
- Tags: Python 2
- Uploaded using Trusted Publishing? No
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1da74b2a4a49ea72cf67190ab24d90e372890146a3f0311737b913d73c4d098b
|
|
| MD5 |
f481a4aeb03c28e147c1fa4eab4073f5
|
|
| BLAKE2b-256 |
887edc749c10927ba615df82e1ea21096edc01a5d0b2e6c7c37a4ba224ecfd6f
|