Flexible Dict
A flexible way to access dict data instead of built-in dict.
Installation
pip install flexible-dict
Usage
Define a dict class and access value
Use a decorator json_object to make class to be a flexible dict.
from flexible_dict import json_object, MISSING
@json_object
class A:
i: int = 3
j: str = "init value"
s: float
g: int = MISSING
a = A()
print(a) # actual is a dict
print(a.i) # access value via x.y
print(a.j)
a.j = "update value" # set value
print(a['j']) # access value via native dict way
Build a json_object class from json data
Suppose there is a file named a.py with content
{
"a": 1,
"b": "two",
"c": {
"d": 4,
"e": "li"
}
}
Run the script bellow
python -m flexible_dict build_class --name A --file a.json --output a.py
Then a file named a.py will be generated
from flexible_dict import json_object
@json_object
class A:
a: int
b: str
c: dict
Metadata
Release files for flexible-dict 2.3.2
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 |
|---|---|---|---|---|
| flexible_dict-2.3.2.tar.gz | 17.8 kB | Without provenance | Details for flexible_dict-2.3.2.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| flexible_dict-2.3.2-py3-none-any.whl | Python 3 | none | any | Details for flexible_dict-2.3.2-py3-none-any.whl |
Total release size: 36.1 kB
Release files / flexible_dict-2.3.2.tar.gz
| Download URL | flexible_dict-2.3.2.tar.gz |
|---|---|
| Size | 17.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
d2eb9854a7755d849b6616813ac0e95116d6a2440c7796d06f24aa04b3b5f29f
|
|
BLAKE2b-256 checksum How to use checksums |
d5a0c89ba550883c28229f0ef3b0dd0cdb678a20d458aa3c726959da9003dc10
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Release files / flexible_dict-2.3.2-py3-none-any.whl
| Download URL | flexible_dict-2.3.2-py3-none-any.whl |
|---|---|
| Size | 18.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
269640bdb4689bed01345c1d06146be63e523e23ec05226662365bcc06bf20e1
|
|
BLAKE2b-256 checksum How to use checksums |
569e2accd799f692dc426a316f8495c27b556b9470d75bf56555dffed0c82fa7
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Security for flexible-dict 2.3.2
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.