We're back after a server migration that caused effbot.org to fall over a bit harder than expected. Expect some glitches.

The __getattr__ method

__getattr__(self, name)

Called when an attribute lookup has not found the attribute in the usual places (i.e. it is not an instance attribute nor is it found in the class tree for self). name is the attribute name. This method should return the (computed) attribute value or raise an AttributeError exception.

Note that if the attribute is found through the normal mechanism, __getattr__ is not called. (This is an intentional asymmetry between __getattr__ and __setattr__.) This is done both for efficiency reasons and because otherwise __setattr__ would have no way to access other attributes of the instance. 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). See the __getattribute__ method for a way to actually get total control in new-style classes.