Is there a built-in function to print all the current properties and values of an object?

fuentesjr picture fuentesjr · Oct 10, 2008 · Viewed 921.1k times · Source

So what I'm looking for here is something like PHP's print_r function.

This is so I can debug my scripts by seeing what's the state of the object in question.

Answer

Jeremy Cantrell picture Jeremy Cantrell · Oct 11, 2008

You want vars() mixed with pprint():

from pprint import pprint
pprint(vars(your_object))