Skip to content

Instantly share code, notes, and snippets.

@truetone
Created September 29, 2014 18:37
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 truetone/67e1ce7f857c0f8c6146 to your computer and use it in GitHub Desktop.
Save truetone/67e1ce7f857c0f8c6146 to your computer and use it in GitHub Desktop.
Handy Python Console Snippets
# 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