get attribute from a parent class
Steve
steve at hotmail.com
Sun Aug 1 21:32:57 EDT 2004
Hi,
I have a nested class declaration such as:
class A:
def __init__(self):
self.var = "A's variable"
# end def
class B:
def __init__(self):
self.var2 = "B's variable"
# end def
# end class B
# end class A
What I want to do is to be able to get class A's 'var' variable from the
nested class B. For example, I want to be able to do something like:
print "I can see you %s" % a.var
but... I don't want to make 'var' a class variable. I want it to be an
instance variable but still be viewable by the inner class B. Is this
possible? Any suggestions? Thanks
Steve
More information about the Python-list
mailing list