28 Aug
2001
28 Aug
'01
5:51 p.m.
On Sunday 26 August 2001 00:09, Dieter Maurer wrote:
Say you have an instance of a class MyClass with attributes myattr1 and myattr2; then you change the class definition for MyClass adding myattr3.
Thomas Olsen writes: 2. Python calls "__getattr__" only the normal lookup was not successful. The normal lookup will find the class attribute "myattr3", "__getattr__" would not be called.
But if the object was instantiated before adding myattr3 to the class definition the objects __dict__ wouldn't contain it and you would get an AttributeError when trying to access it if you didn't implement __getattr__? -- Regards, Thomas Olsen http://www.tanghus.dk