wield.bunch
Utility classes providing "Bunch" containers. These are dictionaries with attribute access of the elements. They wrap any lower level dictionaries they output, so the interface mimics the "struct" container from Matlab.
Bunch
The Bunch class is a lightweight wrapper for dictionaries to allow attribute access as a means to access elements with less syntax. Bunch does not copy assigned dictionaries, it wraps them. This is unlike some other implementations such as gwinc.Struct.
d = dict(A=1, B=2, d2=dict(C=1))
b1 = Bunch(d)
print(b1.A)
print(b1.d2.C)
or
b2 = dict(A=1, B=2, d2=dict(C=1))
print(b2.A)
print(b2.d2.C)
A useful pattern while developing and debugging code, particularly while refactoring large blocks of code into functions is
def code_block(arg1, arg2, arg3, ...):
...
a = 1
b = 2
...
return Bunch(locals())
ret = code_block(...)
ret.a
which is a lightweight way to access elements from the code_block that is promoted into a function.
DeepBunch
There are a collection of more advanced containers DeepBunch allows speculative access of elements, such that if it is missing an attribute, a temporary is created such that
A = DeepBunch()
A.B.C.D = 1
is acceptable.
and
if A.B.C.E:
raise Exception('The above test evaluates to False')
and in this case, no intermediate dictionaries are actually created until a value is assigned to a leaf.
HDFDeepBunch
h5py is not a required dependency of wield.bunch, but if it is installed
then one can import the HDFDeepBunch, which provides a similar interface to
the DeepBunch, but uses HDF5 files as a back-end, with internal handling of
numpy arrays.
Metadata
Release files for wield.bunch 0.9.9
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 |
|---|---|---|---|---|
| wield.bunch-0.9.9.tar.gz | 23.1 kB | Without provenance | Details for wield.bunch-0.9.9.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| wield.bunch-0.9.9-py3-none-any.whl | Python 3 | none | any | Details for wield.bunch-0.9.9-py3-none-any.whl |
Total release size: 51.6 kB
Release files / wield.bunch-0.9.9.tar.gz
| Download URL | wield.bunch-0.9.9.tar.gz |
|---|---|
| Size | 23.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
855fc2883c0eb14aebefe14c4374e52fdf419870499561cf5c37ad139a58778c
|
|
BLAKE2b-256 checksum How to use checksums |
52b7c2f9fb205eb5008184d564b4f7654a87dbb366f76d2b0dd6e4ffd139a680
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/0.0.0 pkginfo/1.8.2 readme-renderer/35.0 requests/2.25.1 requests-toolbelt/0.9.1 urllib3/1.26.9 tqdm/4.64.0 importlib-metadata/4.11.4 keyring/23.5.1 rfc3986/2.0.0 colorama/0.4.4 CPython/3.9.13
|
Release files / wield.bunch-0.9.9-py3-none-any.whl
| Download URL | wield.bunch-0.9.9-py3-none-any.whl |
|---|---|
| Size | 28.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
fa8b350ea8cf4ee4aadfa29ad196b73cae5ae9a18a25f1d960c60554577e2828
|
|
BLAKE2b-256 checksum How to use checksums |
a67588f405d339fb6c8e3123a099ec5e67300a97eaea521b706cfb29d45f52d0
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/0.0.0 pkginfo/1.8.2 readme-renderer/35.0 requests/2.25.1 requests-toolbelt/0.9.1 urllib3/1.26.9 tqdm/4.64.0 importlib-metadata/4.11.4 keyring/23.5.1 rfc3986/2.0.0 colorama/0.4.4 CPython/3.9.13
|
Security for wield.bunch 0.9.9
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.