I normally use @property
to avoid situations such as:
def __init__(self, ...):
self.element = self._getElement()
so that I simply use:
@property
def element(self):
...
However this is not very handy when the decorated function performs expensive computations, and if self.element is been called in many parts and different ways, then the computations are performed for every single call.
Is there a way to avoid this, maybe storing the computations results ? Or am I just using @property in the wrong way ?