accessor/mutator functions
Diez B. Roggisch
deetsNOSPAM at web.de
Fri Feb 25 11:11:36 EST 2005
> Because if so, does the term 'lazy evaluation' refer to the fact that
> instead of:
No, it is a common technical term. It means that a value is computed the
time it is requested for the first time.
Like this:
class Foo(object):
def __init__(self):
self.__bar = None
def getBar(self):
if self.__bar is None:
self.__bar = some_lengthy_computation()
return self.__bar
That you can make bar a property of Foo is unrelated to this.
Another reason to use properties is if the value is always or at least
frequently a freshly computed one.
--
Regards,
Diez B. Roggisch
More information about the Python-list
mailing list