Trouple accessing python superclass attributes [duplicate]
问题 This question already has answers here : Python method name with double-underscore is overridden? (2 answers) Closed 5 years ago . I have two classes that loosely take the form below: class Foo: def __init__(self, foo): self.__foo = foo class Bar(Foo): def bar(self): print self.__foo When I try to invoke the bar method on an instance of Bar , it fails. b = Bar('foobar') b.bar() Result: Traceback (most recent call last): File "foobar.py", line 14, in <module> b.bar() File "foobar.py", line 10,