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.
|