Lloyd Kvam <pyt...@venix.com> writes: > If the value will be computed on demand, __getattr__ is one way to go. > def __getattr__(self, attr): > if attr == 'foo': > return self.compute_foo() > elif .... > else: > raise AttributeError( attr + ' is invalid name') > > This is the 'traditional' approach. __getattr__ is *only* called when > an attribute is not found. If you wanted to save the computed value, so > that __getattr__ was no longer used: > self.__dict__['foo'] = self.compute_foo() > return self.foo > > HTH
Very much so! -- Thanks, Paul _______________________________________________ gnhlug-discuss mailing list gnhlug-discuss@mail.gnhlug.org http://mail.gnhlug.org/mailman/listinfo/gnhlug-discuss/