New submission from Andrew Shuiu <as...@bitdefender.com>: Interpreter do not fill in __dict__ attribute of a class which has atributes. dir() shows them, but not __dict__. It works only when attributes are created dynamically at runtime, such as class.attribute = value, not in class definition. Behaviour is the same on py2.6.4 and py3.1.
Python 3.1.1 (r311:74483, Aug 17 2009, 17:02:12) [MSC v.1500 32 bit (Intel)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> class MyClass: ... myattr = 0 ... >>> inst = MyClass() >>> print(inst.__dict__["myattr"]) Traceback (most recent call last): File "<stdin>", line 1, in <module> KeyError: 'myattr' >>> but in this code it works fine: class MyClass: myattr = 0 inst = MyClass() inst.myattr = 1 print(inst.__dict__["myattr"]) So __dict__ do not contain the attributes of an instantiated object, as it should be, according to documentation. ---------- components: Build, Windows messages: 99595 nosy: asuiu severity: normal status: open title: __dict__ Exception using class attributes type: behavior versions: Python 2.6, Python 3.1 _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue7968> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com