Issue 1419989: class dictionary shortcircuits getattr (original) (raw)
page 3.3.2 of Language Reference states:
"....Note that at least for instance variables, you can fake total control by not inserting any values in the instance attribute dictionary (but instead inserting them in another object)."
A counterexample (doctest style):
class Foo: ... bar = None ... def getattr( self, attr ): ... return 'boo' ... f = Foo() print "bar: ",f.bar bar: None
'bar' in class dictionary (not just in instance dictionary) also causes getattr not to be called.
BTW.. above in the doc, it says that getattr called only if "normal methods" can't find attribute. So this would seem a documentation bug.
However, right now at least, I would prefer if the instance dictionary alone were decisive.