Custom Dictionary with glom get, set and del methods
Project description
glom-dict
Custom Dictionary with glom path compatible get, set and delete methods.
https://glom.readthedocs.io/en/latest/
For easy access to and operations on nested data.
Installation
python -m pip install glom-dict
Examples
>>> from glom_dict import GlomDict
>>> d = GlomDict(my_dict={"a": {"b": "c"}})
>>> d["my_dict.a.b"]
'c'
>>> d["my_dict.a.b] = "C"
>>> d["my_dict.a.b]
'C'
Better error messages.
>>> d = GlomDict(**{'a': {'b': None}})
>>> d["a.b.c"]
Traceback (most recent call last):
...
PathAccessError: could not access 'c', index 2 in path Path('a', 'b', 'c'), got error: ...
Glom Paths
from glom_dict import GlomDict, Path
>>> d = GlomDict({"a": {"b": ["works", "with", "lists", "too"]}})
>>> d[Path("a", "b", 0)]
'works'
For more examples refer to the excellent glom
tutorial.
https://glom.readthedocs.io/en/latest/tutorial.html
Details
Based on collections.UserDict
Implemented methods
-
__getitem__
-glom.glom()
-
__setitem__
-glom.assign()
-
__delitem__
-glom.delete()
-
update
- Works but no special behavior
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
glom-dict-0.0.1a0.tar.gz
(3.5 kB
view hashes)
Built Distribution
Close
Hashes for glom_dict-0.0.1a0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | a81a0cc5be9ee8f9a588a8103a3341ec193dcd61b56609f14ce4a298dfaf2908 |
|
MD5 | b89c508517c73c151a987b8f076c57a9 |
|
BLAKE2b-256 | 36460402c1b9e57496de3d29b2554c7cbd9e2efacd608bff6c16ea1e5aaaf5d9 |