struct-tools
Printing dicts (and objects) legibly: keys aligned, arrays summarized,
nested reprs indented. Plus attribute (dot) access.
aligned: render key-value pairs with the keys aligned, summarizing arrays and indenting nestedreprs to their key.AlignedDict: a dict printed byaligned.DotDict: the same, plus attribute (dot) style access.AlignedRepr: provides__repr__(for subclassing) viaaligned.get0: the first value of a dict.
TODO
- Put DotDict and AlignedDict each in their own module
Changes in 0.3.0
The printing was replaced by the (much smaller) repr written for
MiniRes, which now shares it.
Consequently:
- The package is now only about printing dicts (plus dot access): the
dict/list utilities --
intersect,complement,prodct,transpsand thetranspose_*family,deep_getattr,deep_hasattr,flexcomp-- are gone. They originated in, and are already vendored by, DAPPER (dapper/tools/struct.py). 595 -> 190 lines. alignedandAlignedReprare new;NicePrintis an alias of the latter.printoptsis gone barindent;MIN_LINEWIDTHtoo.- Keys are no longer quoted,
__str__is no longer distinct from__repr__, and the line width is fixed (70) rather than the terminal's, so that output is reproducible. - Recursion is guarded by the stdlib's
reprlib.recursive_repr(...), rather than by hand. - numpy stays an optional, lazy dependency: arrays are summarized if it is already imported, and it is never imported on its account.
See alternatives:
- https://github.com/mewwts/addict
- https://github.com/ducdetronquito/scalpl
- https://github.com/srevenant/dictlib
- https://pypi.org/project/dict/
- https://pypi.org/project/dicty/
- https://pypi.org/project/print-dict/
- https://pypi.org/project/dictionaries/
- https://github.com/wolever/pprintpp
Answer SO.com questions: https://www.google.com/search?q=python+aligned+dict&oq=python+aligned+dict
Metadata
Release files for struct-tools 0.3.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 | |
|---|---|---|---|
| struct_tools-0.3.0.tar.gz | 4.6 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| struct_tools-0.3.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 9.6 kB
Release files / struct_tools-0.3.0.tar.gz
| Download URL | struct_tools-0.3.0.tar.gz |
|---|---|
| Size | 4.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
c5a8cd299194b4d5e2d2a34945e213c9dfebdc0dfd023b8c56e32e084b996b8b
|
|
BLAKE2b-256 checksum How to use checksums |
199c1f4cbf78133841d8b3c4a8dcf05bd07a3a49d7a108de86d81eebd0a1679e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.12.1 {"installer":{"name":"uv","version":"0.12.1","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
|
Release files / struct_tools-0.3.0-py3-none-any.whl
| Download URL | struct_tools-0.3.0-py3-none-any.whl |
|---|---|
| Size | 5.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
92ce7f4f8828e4b96f233b9b3521f98e3e69f3212d85e9c61625ed15998ddeec
|
|
BLAKE2b-256 checksum How to use checksums |
6dfa19b8b52485183eaa5458071de377a5f0e4a3f2e29d217ad3dff328e9ce7d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.12.1 {"installer":{"name":"uv","version":"0.12.1","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
|