Re: update attribute - (newbie)

2006-12-20 Thread Gabriel Genellina
At Tuesday 19/12/2006 11:49, Larry Bates wrote: > I would like to have it that when I ask for p, method _get_p is always > called so that attribute can be updated. How can I have this > functionality here? thanks > Something like this? class A: def __init__(self): self.t=4 r

Re: update attribute - (newbie)

2006-12-19 Thread Larry Bates
Bruce wrote: class A: > ... def __init__(self): > ... self.t = 4 > ... self.p = self._get_p() > ... def _get_p(self): > ... return self.t > ... a = A() a.p > 4 a.t += 7 a.p > 4 > > I would like to have it that when I ask for p, method _get_p is always > called so t

Re: update attribute - (newbie)

2006-12-19 Thread Diez B. Roggisch
Bruce wrote: class A: > ... def __init__(self): > ... self.t = 4 > ... self.p = self._get_p() > ... def _get_p(self): > ... return self.t > ... a = A() a.p > 4 a.t += 7 a.p > 4 > > I would like to have it that when I ask for p, method _get_p is always > called so

update attribute - (newbie)

2006-12-19 Thread Bruce
>>> class A: ... def __init__(self): ... self.t = 4 ... self.p = self._get_p() ... def _get_p(self): ... return self.t ... >>> a = A() >>> a.p 4 >>> a.t += 7 >>> a.p 4 I would like to have it that when I ask for p, method _get_p is always called so that attribute can be updated. How can I