Skip to content

Instantly share code, notes, and snippets.

@shawnoster
Forked from EdwardBetts/pprint_color.py
Last active December 27, 2018 20:47
Show Gist options
  • Save shawnoster/311240922fd8435758c450d234d8c27a to your computer and use it in GitHub Desktop.
Save shawnoster/311240922fd8435758c450d234d8c27a 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, JsonLexer
from pygments.formatters import TerminalFormatter
from pprint import pformat
def ap(obj):
'''Faked Awesome Print'''
print(highlight(pformat(obj), PythonLexer(), TerminalFormatter()))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment