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?


--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to