Skip to content

gh-145217: Add colour to pprint output#145218

Open
hugovk wants to merge 6 commits intopython:mainfrom
hugovk:3.15-pprint-colour
Open

gh-145217: Add colour to pprint output#145218
hugovk wants to merge 6 commits intopython:mainfrom
hugovk:3.15-pprint-colour

Conversation

@hugovk
Copy link
Copy Markdown
Member

@hugovk hugovk commented Feb 25, 2026

Example:

import pprint

data = ["spam", "eggs", ("lumberjack", "knights"), "ni", 42, None]
data.insert(0, data)

pprint.pp(data)
pprint.pprint(data)
pprint.PrettyPrinter().pprint(data)
image

📚 Documentation preview 📚: https://cpython-previews--145218.org.readthedocs.build/

@hugovk hugovk requested a review from AA-Turner as a code owner February 25, 2026 14:20
@hugovk hugovk added type-feature A feature request or enhancement stdlib Standard Library Python modules in the Lib/ directory labels Feb 25, 2026
@StanFromIreland

This comment was marked as resolved.

Comment thread Lib/pprint.py
from io import StringIO as _StringIO

lazy import _colorize
lazy from _pyrepl.utils import disp_str, gen_colors
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Steve won't be happy: #145035

(We could move it, #142699)

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this a blocker?

Or if that move later happens, we can then update this code in a similar way?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking at #145159 's scope, it seems so, but it's up to @zooba.

@StanFromIreland

This comment was marked as resolved.

@hugovk

This comment was marked as resolved.

@johnslavik johnslavik self-requested a review April 10, 2026 10:13
Comment thread Doc/whatsnew/3.15.rst
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

awaiting core review stdlib Standard Library Python modules in the Lib/ directory type-feature A feature request or enhancement

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants