properties setting each other
mk
mrkafk at gmail.com
Wed Sep 3 11:40:43 EDT 2008
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._internalval=val
>
> def fsetvalue(self, val):
> self._setvalue(val)
> self._setsquare=pow(val,2)
>
Thanks for that, I'll keep that in mind.
> 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).
Hmm, why? Is the line of thinking smth like: because the variables
should be kept to minimum and they should be calculated at the moment
they are needed?
More information about the Python-list
mailing list