Skip to content

Instantly share code, notes, and snippets.

@AtHeartEngineer
Forked from EdwardBetts/pprint_color.py
Created July 7, 2018 01:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save AtHeartEngineer/116f42a97447d19d56c1baa3c144875b to your computer and use it in GitHub Desktop.
Save AtHeartEngineer/116f42a97447d19d56c1baa3c144875b 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