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
>>> my_path = Path("a", "b", 1)
>>> d = GlomDict({"a": {"b": ["it", "works", "with", "lists", "too"]}})
>>> d[my_path]
'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() -
assign-glom.assign()- can passmissingcallable to automatically backfill missing structures. -
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
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 glom-dict-0.0.2a0.tar.gz.
File metadata
- Download URL: glom-dict-0.0.2a0.tar.gz
- Upload date:
- Size: 3.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.1.13 CPython/3.10.4 Darwin/21.5.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
61d92dc9befb3ee2c058fd05b1fff102160507c6b0a3c1bc60851b30de06d14f
|
|
| MD5 |
4b5e45ef934f7417fba26260642d6b36
|
|
| BLAKE2b-256 |
04936eef46f07bb6d4f049a0a5cbe4d41d14e4a3a63c15abd0ca34580fd26bb7
|
File details
Details for the file glom_dict-0.0.2a0-py3-none-any.whl.
File metadata
- Download URL: glom_dict-0.0.2a0-py3-none-any.whl
- Upload date:
- Size: 3.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.1.13 CPython/3.10.4 Darwin/21.5.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e24f5dd34bc85f32e2dbf59549516deef3197fe4ad66d2a9968acb5ea48c2339
|
|
| MD5 |
fb437ef5318d25f7a05e999a537d1a55
|
|
| BLAKE2b-256 |
b67ce9bd98449a8b3b9bd10dec5ddb42503040ac4b633da266b56cee5a608614
|