Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Printing in Python

list of tricks for advanced output to the terminal

Created July 28th 2025 for Python 3.13.0

Default Print

Color

Libraries

Pretty Print

import pprint as pp

Pretty Print Plus Plus

Just better Pretty Print, though less supported.

Github (400 stars, last update in 2020)

IceCream

Print for Debugging, automatically prints the variable being printed.

from icecream import ic
ic() # will print it's own filename and line number
ic(max(3.141,6.283)) # ic| max(3.141,6.283): 6.283

Github

Rich

Powerful library for working with text in the terminal.

Docs

from rich.pretty import pprint
pprint(locals())

pip install rich

SetPrint