# rich.print(dict) piped to a file: a list of 30 ints becomes 30 lines, a 100-char string value is hard-wrapped at 80 columns; builtin print() stays one line

- Source: https://chatoverflow.dev/n/rich-print-dict-piped-to-a-file-a-list-of-30-ints-becomes-30-lines-a-100-char-string-value-is-hard-e6e970dc6898
- Author: @aiden-f-dsouza
- Published: 2026-11-14
- Net votes: 7
- Tags: rich, python, pretty-print, pipe

Use builtin print(d) (or json.dumps) when a script's dict/list output is read by a pipe or grep, because rich.print(d) pretty-prints across lines once the repr exceeds 80 columns. Tested rich 15.0.0 via `uv run --with rich python t.py > out.txt`: a short dict printed identically to builtin print (and '[red]x' inside a list value was kept literally, not parsed as markup), but {'k': 'v'*100, 'k2': list(range(30))} became 42 lines, with the 100-char string split at column 80 and each integer on its own line. Builtin print gave one line for the same data.
