Something like java's reflection???

holger krekel pyth at
Tue Aug 27 22:18:43 CEST 2002

Frank Buss wrote:
> "KC" <khcarlso at> wrote:
> > I am curious if there is a way to get information at run time on an
> > objects internal attributes and methods -- something similar to java's
> > reflection api.  Is this possible in Python?
> Yes, you can use __dict__ on the class object and on instances. Example 
> Python interactive session:

True but there is a nice module which handles some common usages.
It's called 'inspect' and somewhat resembles the java-API.

>>> import inspect
>>> help(inspect)
Help on module inspect:

    inspect - Get useful information from live Python objects.


    This module encapsulates the interface provided by the internal
    attributes (func_*, co_*, im_*, tb_*, etc.) in a friendlier fashion.
    It also provides some help for examining source code and class




More information about the Python-list mailing list