Re: properties setting each other

2008-09-03 Thread Maric Michaud
Le Wednesday 03 September 2008 19:38:13 Bruno Desthuilliers, vous avez écrit : > FWIW, if there's no computation on getting or setting value, you can > make it a plain attribute. Yes, this is the problem with these tiny examples, we don't know at which point we must simplify them... > > But whil

Re: properties setting each other

2008-09-03 Thread Bruno Desthuilliers
Maric Michaud a écrit : Le Wednesday 03 September 2008 17:40:43 mk, vous avez écrit : 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 th

Re: properties setting each other

2008-09-03 Thread Maric Michaud
Le Wednesday 03 September 2008 17:40:43 mk, vous avez écrit : > > 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

Re: properties setting each other

2008-09-03 Thread mk
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

Re: properties setting each other

2008-09-03 Thread Maric Michaud
Le Wednesday 03 September 2008 16:44:10 Maric Michaud, vous avez écrit : >          def _setsquare(self, v) : >                  # some extra logic here >                  self._square = s > >          def fsetsquare(self,s): >                  self._setsquare(s) >                  self._setvalue =

Re: properties setting each other

2008-09-03 Thread Bruno Desthuilliers
mk a écrit : Hello everyone, I try to set two properties, "value" and "square" in the following code, and arrange it in such way that setting one property also sets another one and vice versa. But the code seems to get Python into infinite loop: > >>> import math >>> class Squared2(object)

Re: properties setting each other

2008-09-03 Thread Diez B. Roggisch
mk schrieb: Hello everyone, I try to set two properties, "value" and "square" in the following code, and arrange it in such way that setting one property also sets another one and vice versa. But the code seems to get Python into infinite loop: >>> import math >>> class Squared2(object):

Re: properties setting each other

2008-09-03 Thread Maric Michaud
Le Wednesday 03 September 2008 15:57:50 mk, vous avez écrit : > I try to set two properties, "value" and "square" in the following code, > and arrange it in such way that setting one property also sets another > one and vice versa. But the code seems to get Python into infinite loop: > >  >>> impor

Re: properties setting each other

2008-09-03 Thread Wojtek Walczak
On Wed, 3 Sep 2008 14:31:17 + (UTC), Wojtek Walczak wrote: > class Square(object): >def __init__(self, val): > self._square = pow(val, 2) > self._value = math.sqrt(self.square) ^^ or just: self._value = val :-) -- Regards, W

Re: properties setting each other

2008-09-03 Thread Wojtek Walczak
On Wed, 03 Sep 2008 15:57:50 +0200, mk wrote: > I try to set two properties, "value" and "square" in the following code, > and arrange it in such way that setting one property also sets another > one and vice versa. But the code seems to get Python into infinite loop: > Is there a way to achiev