skillfed

wadler-lindig

A Wadler–Lindig pretty-printer for Python.

wadler-lindig v0.1.7 4.9M downloads/30d#2,214 on PyPI48
Permissive license Apache License Version 2.0, January 2004 http://www.apache.org/licenses/ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 1. Definitions. "License" shall mean the terms and conditions for… (full text in the JSON record) Active released

What it is and what it does

Wadler–Lindig is a pretty-printer for Python objects that implements the Wadler–Lindig algorithm, a layout algorithm that breaks lines more intelligently than the built-in pprint module. Instead of pprint's right-aligned continuation style, it produces vertically compact output that respects a target width and indentation level. The library has zero dependencies and is implemented in pure Python.

It is designed for two main use cases: replacing pprint in error messages and debug output where horizontal space matters, and creating custom pretty-printed representations for complex types like nested dataclasses or other tree-like structures. You can customize formatting either by adding a `__pdoc__` method to your class or by passing a `custom` formatter to the pprint call. It also supports ANSI escape codes and provides concise summaries for NumPy arrays and similar types.

Use it for:

  • Format error messages and debug output that fit within terminal width constraints without excessive line wrapping.
  • Create readable reprs for nested dataclasses or custom types by implementing the `__pdoc__` method.
  • Display NumPy arrays in concise form (e.g., `f64[2,3](numpy)`) rather than full element dumps.
  • Add ANSI escape codes to pretty-printed output for terminal-based debugging and logging.
  • Replace pprint in test assertions or logging where output readability and compactness are both important.

Worth the install?

AI-flagged interpretation of the facts on this page — verify before relying

Formats Python objects for readable output using the Wadler–Lindig pretty-printing algorithm, which breaks lines more intelligently than the built-in pprint to consume less horizontal space.

Yes. It is a lightweight, dependency-free tool with active maintenance and no known vulnerabilities. Install it if you need better-formatted object output than pprint in error messages, debug logs, or custom repr implementations. The Alpha status is not a blocker—the algorithm itself is well-established—but be aware the API may change in minor ways before 1.0.

Install

wadler-lindig on PyPI

pip

pip install wadler-lindig

uv

uv add wadler-lindig

poetry

poetry add wadler-lindig

Installing wadler-lindig

Before you install

Low friction: pure Python with zero runtime dependencies, distributed as a wheel. Active maintenance with recent commits and no known vulnerabilities.

License in practice

Apache License 2.0 (permissive): you can use, modify, and distribute this code freely in commercial and private projects, provided you include a copy of the license and note any changes you make.

Quickstart

pip install wadler_lindig

import wadler_lindig as wl

obj = {"key": [1, 2, 3], "nested": {"x": "value"}}
wl.pprint(obj, width=30)

Requires Python 3.10 or later.

Verify before relying

  • Whether the library handles all standard Python types (e.g., sets, frozensets, custom iterables) beyond the documented examples.
  • Performance characteristics when formatting very large or deeply nested structures.
  • Stability of the API given the 'Alpha' development status (0.1.7 version).

Package facts

License Apache License Version 2.0, January 2004 http://www.apache.org/licenses/ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 1. Definitions. "License" shall mean the terms and conditions for… (full text in the JSON record) (permissive)
Python support supports the current Python release (>=3.10)
Install friction low — pure-Python wheel
Runtime dependencies none
Maintenance actively maintained — 422 days since the last release
Last repo commit
First released
Downloads 4,850,104/month — #2,214 on PyPI (30-day window, as of 2026-08-14)
Known vulnerabilities none known (OSV.dev, checked 2026-08-14)

Evidence: wadler_lindig-0.1.7-py3-none-any.whl

Keywords: leijen, lindig, pprint, pretty-printer, wadler

Development Status :: 3 - AlphaLicense :: OSI Approved :: Apache Software LicenseNatural Language :: EnglishProgramming Language :: Python :: 3

Tags

pretty printer for python objectswadler lindig algorithmcompact pprint alternativecustom repr formattingnested dataclass pretty printingansi color pretty printspace-efficient object formatting
pretty-printingdebuggingformatting

More Utilities packages