Class variable inheritance
HPJ
henrypijames at gmail.com
Wed Sep 9 02:05:30 EDT 2009
And by the way, the reason I've come across this problem at all is
because I have something like this:
class A:
class X:
n = 'a'
x = X()
class B(A):
class X(A.X):
n = 'b'
# x = X()
The line commented out was originally not there, but I found out I had
to add it if I wanted B().x.n to be 'b' instead of 'a'.
I might be wrong, but aren't there some (non-obscure) OOP language in
which the equivalent code (without the out-commented line) would have
made B().x an object of type B.X instead of A.X?
More information about the Python-list
mailing list