Python’s Version of print_r – pprint

Update: Try and use iPython Notebox instead….makes this stuff easy by default :)

Need to have a ‘pretty’ version of a dictionary, in PHP I would use:

print “<pre>”
print_r($array);

but in python……?

Use pprint

import pprint
pp = pprint.PrettyPrinter(indent=4)
pp.pprint(thing)

All the info you need: Pretty Print

 

Leave a Reply

Your email address will not be published. Required fields are marked *