__getattr__ and __setattr__ Catch Attribute References : getattr « Class « Python Tutorial






class empty: 
    def __getattr__(self, attrname): 
        if attrname == "age": 
            return 40 
        else: 
            raise AttributeError, attrname 

X = empty(  ) 
X.age








11.18.getattr
11.18.1.__getattr__ and __setattr__ Catch Attribute References