में मूल सदस्य चर का उपयोग नहीं कर सकता है मैं एक विस्तारित वर्ग से अभिभावक सदस्य चर का उपयोग करने का प्रयास कर रहा हूं।पायथन
AttributeError: type object 'Mother' has no attribute '_haircolor'
क्या मैं गलत कर रहा हूँ: लेकिन निम्नलिखित कोड चल रहा है ...
class Mother(object):
def __init__(self):
self._haircolor = "Brown"
class Child(Mother):
def __init__(self):
Mother.__init__(self)
def print_haircolor(self):
print Mother._haircolor
c = Child()
c.print_haircolor()
मुझे इस त्रुटि हो जाता है?
एक बेवकूफ – Yarin