Something like java's reflection???

Frank Buss fb at frank-buss.de
Tue Aug 27 16:26:28 EDT 2002


Frank Buss <fb at frank-buss.de> wrote:

> Yes, you can use __dict__ on the class object and on instances.

Looks like this doesn't work on internal types. You can call it on string, 
after importing string, but I didn't found a way to call it on a string 
object:

>>> a="test"
>>> a.__dict__
Traceback (most recent call last):
  File "<stdin>", line 1, in ?
AttributeError: 'str' object has no attribute '__dict__'
>>> string.__dict__
Traceback (most recent call last):
  File "<stdin>", line 1, in ?
NameError: name 'string' is not defined
>>> import string
>>> string.__dict__
[ snipped long list...]
>>> a.__dict__
Traceback (most recent call last):
  File "<stdin>", line 1, in ?
AttributeError: 'str' object has no attribute '__dict__'

-- 
Frank Buß, fb at frank-buss.de
http://www.frank-buss.de, http://www.it4-systems.de



More information about the Python-list mailing list