Something like java's reflection???

Frank Buss fb at
Tue Aug 27 18:33:03 CEST 2002

"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:

>>> class t:
...   def hello(self):
...     self.data1 = "hello"
>>> x = t()
>>> x.__dict__
>>> t.__dict__
{'__doc__': None, '__module__': '__main__', 'hello': <function hello at 
>>> x.hello()
>>> x.__dict__
{'data1': 'hello'}

Frank Buß, fb at,

More information about the Python-list mailing list