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()) |
This comment has been minimized.
This comment has been minimized.
Thanks for this! |
This comment has been minimized.
This comment has been minimized.
Thanks! |
This comment has been minimized.
This comment has been minimized.
Thanks! |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This comment has been minimized.
Thanks a bunch! Works well in Jupyter notebooks. (Extra parentheses needed for Python 3.)