andrea.crotti.0 at gmail.com
Thu Nov 1 22:38:53 CET 2012
Seeing the wonderful "lazy val" in Scala I thought that I should try to
get the following also in Python.
The problem is that I often have this pattern in my code:
self._var = None
if self._var is None:
self._var = long_computation()
which is quite useful when you have some expensive attribute to compute
that is not going to change.
I was trying to generalize it in a @lazy_property but my attempts so far
failed, any help on how I could do that?
What I would like to write is
and this should imply that the long_computation is called only once..
More information about the Python-list