What is a Python equivalent of PHP's var_dump()?

Zoredache picture Zoredache · Dec 21, 2008 · Viewed 290.4k times · Source

When debugging in PHP, I frequently find it useful to simply stick a var_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?

Answer

Jan picture Jan · May 22, 2010

I think the best equivalent to PHP's var_dump($foo, $bar) is combine print with vars:

print vars(foo),vars(bar)