You want vars() mixed with pprint():
from pprint import pprint
pprint(vars(your_object))
You are really mixing together two different things.
Use dir(), vars() or the inspect module to get what you are interested in (I use __builtins__ as an example; you can use any object instead).
>>> l = dir(__builtins__)
>>> d = __builtins__.__dict__
Print that dictionary however fancy you like:
>>> print l
[‘ArithmeticError’, ‘AssertionError’, ‘AttributeError’,…
or
>>> from pprint import pprint
>>> pprint(l)
[‘ArithmeticError’,
‘AssertionError’,
‘AttributeError’,
‘BaseException’,
‘DeprecationWarning’,
…
>>> pprint(d, indent=2)
{ ‘ArithmeticError’:
‘AssertionError’:
‘AttributeError’:
…
‘_’: [ ‘ArithmeticError’,
‘AssertionError’,
‘AttributeError’,
‘BaseException’,
‘DeprecationWarning’,
…
Pretty printing is also available in the interactive debugger as a command:
(Pdb) pp vars()
{‘__builtins__’: {‘ArithmeticError’:
‘AssertionError’:
‘AttributeError’:
‘BaseException’:
‘BufferError’:
…
‘zip’:
‘__file__’: ‘pass.py’,
‘__name__’: ‘__main__’}