Thanks to everyone for answers..
*but*, if you want to add more logic in the setters, you could want to add two
extra methods :
>
def _setsquare(self , v) :
# some extra logic here
self._square = s
>
def fsetsquare(self ,s):
self._setsquare (s)
self._setvalue = math.sqrt(s)
>
def _setvalue(self, val):
# some extra logic here
self._internalv al=val
>
def fsetvalue(self, val):
self._setvalue( val)
self._setsquare =pow(val,2)
>
extra methods :
>
def _setsquare(self , v) :
# some extra logic here
self._square = s
>
def fsetsquare(self ,s):
self._setsquare (s)
self._setvalue = math.sqrt(s)
>
def _setvalue(self, val):
# some extra logic here
self._internalv al=val
>
def fsetvalue(self, val):
self._setvalue( val)
self._setsquare =pow(val,2)
>
Note that if one property can really be computed from another, this kind of
thing could be considered as bad design (except if the computation is heavy).
thing could be considered as bad design (except if the computation is heavy).
should be kept to minimum and they should be calculated at the moment
they are needed?