Created
September 29, 2014 18:37
-
-
Save truetone/67e1ce7f857c0f8c6146 to your computer and use it in GitHub Desktop.
Handy Python Console Snippets
This file contains hidden or 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
# This works in the Flask debugging console as well. | |
# Very handy for pretty output of Python dictionaries | |
# Source: http://stackoverflow.com/questions/3733554/howto-format-dict-string-outputs-nicely | |
import json | |
x = {'planet' : {'has': {'plants': 'yes', 'animals': 'yes', 'cryptonite': 'no'}, 'name': 'Earth'}} | |
print json.dumps(x, indent=2) | |
""" | |
Output: | |
{ | |
"planet": { | |
"has": { | |
"plants": "yes", | |
"animals": "yes", | |
"cryptonite": "no" | |
}, | |
"name": "Earth" | |
} | |
} | |
""" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment