Skip to content

Instantly share code, notes, and snippets.

@JPalmerGithub
Forked from EdwardBetts/pprint_color.py
Created January 25, 2022 12:21
Show Gist options
  • Save JPalmerGithub/8e88d6221ce04b39fd17392512bdeb2d to your computer and use it in GitHub Desktop.
Save JPalmerGithub/8e88d6221ce04b39fd17392512bdeb2d to your computer and use it in GitHub Desktop.
Python pprint with color syntax highlighting for the console
from pygments import highlight
from pygments.lexers import PythonLexer
from pygments.formatters import Terminal256Formatter
from pprint import pformat
def pprint_color(obj):
print highlight(pformat(obj), PythonLexer(), Terminal256Formatter())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment