Re: Inheriting property functions

2006-10-21 Thread Bruno Desthuilliers
[EMAIL PROTECTED] a écrit : (snip) > The trouble is that get_a and set_a are attributes of the _class > object_ A. Instances of A (and hence, instances of B) will see them, > but the class B will not, Yes it does: >>> class A(object): ... aa = "aa" ... >>> class B(A):pass ... >>> B.aa 'aa

Re: Inheriting property functions

2006-10-21 Thread Diez B. Roggisch
Dustan schrieb: > Looking at this interactive session: > class A(object): > def __init__(self, a): > self.a = a > def get_a(self): return self.__a > def set_a(self, new_a): self.__a = new_a > a = property(get_a, set_a) > > class B(A): > b = p

Re: Inheriting property functions

2006-10-20 Thread Aahz
In article <[EMAIL PROTECTED]>, Dustan <[EMAIL PROTECTED]> wrote: > class A(object): > def __init__(self, a): > self.a = a > def get_a(self): return self.__a > def set_a(self, new_a): self.__a = new_a > a = property(get_a, set_a) > > class B(A): >

Re: Inheriting property functions

2006-10-20 Thread Dustan
Robert Kern wrote: > Dustan wrote: > > Looking at this interactive session: > > > class A(object): > > def __init__(self, a): > > self.a = a > > def get_a(self): return self.__a > > def set_a(self, new_a): self.__a = new_a > > a = property(get_a, set_a) > > > > > >

Re: Inheriting property functions

2006-10-20 Thread Gabriel Genellina
At Friday 20/10/2006 19:49, Dustan wrote: > >>> class A(object): > def get_a(self): return self.__a > def set_a(self, new_a): self.__a = new_a > a = property(get_a, set_a) > > > >>> class B(A): > b = property(get_a, set_a) Use instead: b = property(A.get_a, A.s

Re: Inheriting property functions

2006-10-20 Thread mdsteele
Robert Kern wrote: > Inheritance really doesn't work that way. The code in the class suite gets > executed in its own namespace that doesn't know anything about inheritance. > The > inheritance rules operate in attribute access on the class object later. Right. That was what I should have said,

Re: Inheriting property functions

2006-10-20 Thread Robert Kern
Dustan wrote: > Looking at this interactive session: > class A(object): > def __init__(self, a): > self.a = a > def get_a(self): return self.__a > def set_a(self, new_a): self.__a = new_a > a = property(get_a, set_a) > > class B(A): > b = pro

Re: Inheriting property functions

2006-10-20 Thread mdsteele
Dustan wrote: > B isn't recognizing its inheritence of A's methods get_a and set_a > during creation. > > Why am I doing this? For an object of type B, it makes more sense to > reference the attribute 'b' than it does to reference the attribute > 'a', even though they are the same, in terms of read

Re: Inheriting property functions

2006-10-20 Thread Dustan
Dustan wrote: > Looking at this interactive session: > > >>> class A(object): > def __init__(self, a): > self.a = a > def get_a(self): return self.__a > def set_a(self, new_a): self.__a = new_a > a = property(get_a, set_a) > > > >>> class B(A): > b = pro

Inheriting property functions

2006-10-20 Thread Dustan
Looking at this interactive session: >>> class A(object): def __init__(self, a): self.a = a def get_a(self): return self.__a def set_a(self, new_a): self.__a = new_a a = property(get_a, set_a) >>> class B(A): b = property(get_a, set_a) Tr