
Aug. 25, 2008
12:34 a.m.
Russ Paielli wrote:
Another option is to explicitly "strip off" the "self." by writing "attr = self.attr" to create a local reference to the attribute within the method.
This is very often done for another reason -- it's *much* faster to refer to a local variable than to look up an attribute, so if the attribute is being used more than once or twice, it's more efficient to pull it into a local first. Given that, methods which use attributes of self a lot tend not to look as cluttered as you might expect. -- Greg