Inheriting property functions

Bruno Desthuilliers bdesth.quelquechose at free.quelquepart.fr
Sat Oct 21 17:52:28 EDT 2006


mdsteele at gmail.com 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'
 >>>


> so you have to point to them explicitly with
> A.get_a and A.set_a.

Actually, while the solution is good, the explanation is wrong.




More information about the Python-list mailing list