Skip to main content

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 nested reprs to their key.
  • AlignedDict: a dict printed by aligned.
  • DotDict: the same, plus attribute (dot) style access.
  • AlignedRepr: provides __repr__ (for subclassing) via aligned.
  • 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, transps and the transpose_* family, deep_getattr, deep_hasattr, flexcomp -- are gone. They originated in, and are already vendored by, DAPPER (dapper/tools/struct.py). 595 -> 190 lines.
  • aligned and AlignedRepr are new; NicePrint is an alias of the latter.
  • printopts is gone bar indent; MIN_LINEWIDTH too.
  • 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:

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)

Source distribution for struct-tools 0.3.0
File Size Uploaded
struct_tools-0.3.0.tar.gz 4.6 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for struct-tools 0.3.0
File Interpreter ABI Platform
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}

Release history Release notifications | RSS feed

This release

0.3.0 This release

2 release files

0.2.7

2 release files

0.2.6

2 release files

0.2.5

2 release files

0.2.4

2 release files

0.2.3

2 release files

0.2.2

2 release files

0.2.1

2 release files

0.2.0

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page