当debugging in PHP, I frequently find it useful to simply stick avar_dump()in my code to show me what a variable is, what its value is, and the same for anything that it contains.
What is a good Python equivalent for this?
The best Python equivalent of PHP'svar_dump()is to combineprintwithvars:
print vars(foo),vars(bar)
Another important method if you want to display the value nicely, you can use thepprintmodule. The easiest way to dump all variables with it.
from pprint import pprint
pprint(globals())
pprint(locals())