a dict with key attributes
pip install punktdict
This module provides the PunktDict class, which is a subclass of dict with additional functionality for handling nested dictionaries.
It also provides some configuration options through the dictconfig object.
import sys
from punktdict import PunktDict, dictconfig, convert_to_dict
# Configure PunktDict behavior
dictconfig.allow_nested_attribute_creation = True
dictconfig.allow_nested_key_creation = True
dictconfig.convert_all_dicts_recursively = True
PunktDict._check_forbidden_key = (
lambda self, x: (x.startswith("_ipython") or x == "_repr_mimebundle_")
)
# Create a PunktDict object
d = PunktDict({'popeye': {'mole': {'bole': 'dolle'}}})
# Access and modify nested dictionary values
d['hallo']['baba'] = 11
d.lll.ddd.xxx = 333
# Update PunktDict with new data
d.update({'rrrx': {'xxxxx': 'bbbb'}})
d.rrrx.xxxxxxx = []
d.rrrx.xxxxxxx.append(3)
# Access nested dictionary values using attribute syntax
d['gggg']['xxxxx']['tttt'] = 12
print(d.gggg.xxxxx.tttt)
# Convert PunktDict to a regular dictionary
di = convert_to_dict(d)
---------------
Attributes:
-----------
- allow_nested_attribute_creation: A boolean flag indicating whether PunktDict allows creation of nested attributes. Default is True.
- allow_nested_key_creation: A boolean flag indicating whether PunktDict allows creation of nested keys. Default is True.
- convert_all_dicts_recursively: A boolean flag indicating whether PunktDict recursively converts all nested dictionaries to PunktDict objects. Default is True.
Classes:
--------
- PunktDict: A subclass of dict with additional functionality for handling nested dictionaries.
Functions:
----------
- check_if_compatible_dict: Checks if an object is a compatible dictionary based on its type and attributes.
- convert_to_dict: Recursively converts a PunktDict object or a compatible dictionary to a regular dictionary.
Note:
-----
The `PunktDict` class overrides several methods and provides additional methods to handle nested dictionaries. The configuration options can be modified through the `dictconfig` object. The `convert_to_dict` function can be used to convert a PunktDict object or a compatible dictionary to a regular dictionary.
Metadata
Release files for punktdict 0.11
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 |
|---|---|---|---|---|
| punktdict-0.11.tar.gz | 4.7 kB | Without provenance | Details for punktdict-0.11.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| punktdict-0.11-py3-none-any.whl | Python 3 | none | any | Details for punktdict-0.11-py3-none-any.whl |
Total release size: 10.7 kB
Release files / punktdict-0.11.tar.gz
| Download URL | punktdict-0.11.tar.gz |
|---|---|
| Size | 4.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
e46317d633ab927165aa7e1df82a1ddfcf44068bd1cfb02687c1335248129a00
|
|
BLAKE2b-256 checksum How to use checksums |
f9cfc4cd7742e4f636714d4cf91e1d269df0f679161f325ada06dfdc6fc7d125
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.10.10
|
Release files / punktdict-0.11-py3-none-any.whl
| Download URL | punktdict-0.11-py3-none-any.whl |
|---|---|
| Size | 6.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
c7e73cdced9fe34d93f55443b9719c1fcf037d3124e64dfcfb4d112426fbe8f0
|
|
BLAKE2b-256 checksum How to use checksums |
8adb506414fd5207c9d680b590fe6fd2776e5ef4c577901227d95f83f72d29da
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.10.10
|
Security for punktdict 0.11
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.