Am 28.10.2011 10:01, schrieb Steven D'Aprano: >>>> hasattr(int, '__dict__') # Does the int class/type have a __dict__? > True >>>> hasattr(42, '__dict__') # Does the int instance have a __dict__? > False
Also __dict__ doesn't have to be an instance of __dict__. Builtin types usually have a dictproxy instane as their __dict__. >>> type(int.__dict__) <type 'dictproxy'> >>> int.__dict__["egg"] = "spam" Traceback (most recent call last): File "<stdin>", line 1, in <module> TypeError: 'dictproxy' object does not support item assignment -- http://mail.python.org/mailman/listinfo/python-list