[ZPatterns] AttributeError _v_cache
Steve Alexander
[email protected]
Thu, 18 Oct 2001 23:56:27 +0100
Steve Spicklemire wrote:
> Yes.. in Python I'm used to something like:
>
> class Foo
>
> myFoo = None
>
> def getMyFoo(self):
> if self.myFoo is None:
> self.myFoo = MyFoo()
>
> return self.myFoo
>
> Which seems pretty clear to me!
>
> What's the main advantage of the ComputedAttribute version? Is it just
> sytactical (i.e., it doesn't look like a method call, but rather an
> instance varible)?
With the implementation pattern you see in ZPatterns, once you've set up
the attribute, there is no overhead on each retrieval.
--
Steve Alexander
Software Engineer
Cat-Box limited