I\'m trying to access a parent member variable from an extended class. But running the following code...
class Mother(object):
def __init__(self):
se
You want the instance attribute, not the class attribute, so you should use self._haircolor
.
Also, you really should use super
in the __init__
in case you decide to change your inheritance to Father
or something.
class Child(Mother):
def __init__(self):
super(Child, self).__init__()
def print_haircolor(self):
print self._haircolor
You're mixing up class and instance attributes.
print self._haircolor