Back

Explore Courses Blog Tutorials Interview Questions
0 votes
1 view
in Python by (47.6k points)

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.

1 Answer

0 votes
by (106k points)

Yes, Python has a method that is used to print all current properties and values of an object which is  vars() mixed with pprint():

from pprint import pprint 

pprint(vars(your_object))

Welcome to Intellipaat Community. Get your technical queries answered by top developers!

28.4k questions

29.7k answers

500 comments

94.1k users

Browse Categories

...