How do I look inside a Python object?


I'm starting to code in various projects using Python (including Django web development and Panda3D game development).

To help me understand what's going on, I would like to basically 'look' inside the Python objects to see how they tick - like their methods and properties.

So say I have a Python object, what would I need to print out its contents? Is that even possible?

3/24/2015 7:37:01 PM

Python has a strong set of introspection features.

Take a look at the following built-in functions:

type() and dir() are particularly useful for inspecting the type of an object and its set of attributes, respectively.

11/30/2017 7:26:38 PM

Licensed under: CC-BY-SA with attribution
Not affiliated with: Stack Overflow