Created
March 7, 2014 20:54
-
-
Save rwarren/9419899 to your computer and use it in GitHub Desktop.
python displayhook for pprint by default
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#lifted from http://stackoverflow.com/questions/17248383/pretty-print-by-default-in-python-repl | |
import pprint | |
import sys | |
orig_displayhook = sys.displayhook | |
def myhook(value): | |
if value != None: | |
__builtins__._ = value | |
pprint.pprint(value) | |
__builtins__.pprint_on = lambda: setattr(sys, 'displayhook', myhook) | |
__builtins__.pprint_off = lambda: setattr(sys, 'displayhook', orig_displayhook) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment