Nested Dicts
Python multiple-default dicts, list-keyed dicts, dotted-key dicts and Arrays of Tables classes.
pip install nested_dicts
Examples
DefaultsDictABC
Implement the choose_factory method on a subclass to select a factory. The returned factory is itself called with the key value (unlike collections.defaultdict.missing)
The following 4 examples all define a dictionary subclass d for which
d == {'k': {'sub_dict_key': 'v'}} is True.
NestedDefaultsDict
>>> d = NestedDefaultsDict()
>>> d['k']['sub_dict_key'] = 'v'
ListKeyedDict
>>> d = ListKeyedDict.from_nested_dict({'k': {'sub_dict_key': 'v'}})
>>> d[['k', 'sub_dict_key']]
'v'
ListKeyedNestedDefaultsDict
>>> d = ListKeyedNestedDefaultsDict()
>>> d[['k', 'sub_dict_key']] = 'v'
DottedKeyedNestedDefaultsDict
>>> d = DottedKeyedNestedDefaultsDict()
>>> d['k.sub_dict_key'] = 'v'
TOMLTable
>>> from nested_dicts import TOMLTable
>>> t = TOMLTable()
>>> t['table-1'].update(
... key1 = "some string",
... key2 = 123)
>>> t['table-2'].update(
... key1 = "another string",
... key2 = 456)
>>> t
{'table-1': {'key1': 'some string', 'key2': 123}, 'table-2': {'key1': 'another string', 'key2': 456}}
Values in TOMLTable()s indexed with lists behave like Arrays of Tables, even when only read
>>> from nested_dicts import TOMLTable
>>> t = TOMLTable()
>>> t[['products']].update(
name = "Hammer",
sku = 738594937
)
>>> t[['products']] # empty table within the array
{}
>>> t[['products']].update(
name = "Nail",
sku = 284758393,
color = "gray"
)
>>> t
{'products': [{'name': 'Hammer', 'sku': 738594937}, {}, {'name': 'Nail', 'sku': 284758393, 'color': 'gray'}]}
Metadata
Release files for nested-dicts 0.0.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| nested_dicts-0.0.0.tar.gz | 9.6 kB | Without provenance | Details for nested_dicts-0.0.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| nested_dicts-0.0.0-py3-none-any.whl | Python 3 | none | any | Details for nested_dicts-0.0.0-py3-none-any.whl |
Total release size: 16.3 kB
Release files / nested_dicts-0.0.0.tar.gz
| Download URL | nested_dicts-0.0.0.tar.gz |
|---|---|
| Size | 9.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
42ba1f6d9a583308cb12528c0e849816dc751eefca347f0041f324e2e47ade2d
|
|
BLAKE2b-256 checksum How to use checksums |
ae8cd974236efa6004ae0dd9f9e77e3192664e9f16a33241b2cda907ccec5b99
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.11.0
|
Release files / nested_dicts-0.0.0-py3-none-any.whl
| Download URL | nested_dicts-0.0.0-py3-none-any.whl |
|---|---|
| Size | 6.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
c2f5705f7e42495244cd86844872b30911a5aa29fbfdd2052165052e4ee62b96
|
|
BLAKE2b-256 checksum How to use checksums |
399bb520bcf06910c23fe6795f16972314effc712ba1292a689f534b1a8783b2
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.11.0
|
Security for nested-dicts 0.0.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.