Metadata-Version: 2.4
Name: struct-tools
Version: 0.3.0
Summary: Dicts with attribute access, and printed aligned
Keywords: dict,repr,pretty-print,attribute-access
Author: patnr
Author-email: patnr <patrick.n.raanes@gmail.com>
License-Expression: MIT
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Requires-Python: >=3.8
Description-Content-Type: text/markdown

# struct-tools

Printing dicts (and objects) legibly: keys aligned, arrays summarized,
nested `repr`s indented. Plus attribute (dot) access.

- `aligned`: render key-value pairs with the keys aligned,
  summarizing arrays and indenting nested `repr`s 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](https://github.com/patnr/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](https://github.com/nansencenter/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:

- <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>
