Pretty Print Plus Plus

0.4.0 · active · verified Thu Apr 09

pprintpp is a Python library that provides a drop-in replacement for the standard library's `pprint` module. Its main goal is to produce more aesthetically pleasing and readable output for complex data structures like dictionaries and lists, especially with improved indentation and line wrapping. The current version is 0.4.0, and it generally follows a stable, infrequent release cadence given its focused utility.

Warnings

Install

Imports

Quickstart

This quickstart demonstrates how to use `pprintpp.pprint` to format a complex dictionary. It also includes a comparison with the standard library's `pprint` to highlight the aesthetic differences provided by `pprintpp`.

import pprintpp

data = {
    'name': 'John Doe',
    'age': 30,
    'isStudent': False,
    'courses': [
        {'title': 'History I', 'credits': 3, 'grade': 'A'},
        {'title': 'Math II', 'credits': 4, 'grade': 'B+'},
        {'title': 'Literature', 'credits': 3, 'grade': 'A-'}
    ],
    'address': {
        'street': '123 Main St',
        'city': 'Anytown',
        'zip': '12345'
    }
}

print('--- Using standard pprint ---')
import pprint
pprint.pprint(data)

print('\n--- Using pprintpp ---')
pprintpp.pprint(data)

view raw JSON →