The following code generates an error:
class A(object):
    def say_something(self):
        print(self.foo)
        print(self.__bar)
class B(A):
    def __init__(self):
        self.foo = 'hello'
        self.__bar = 'world'
test = B()
test.say_something()
Printing of 'hello' is successful but 'world' generates the following error:
    print(self.__bar)
AttributeError: 'B' object has no attribute '_A__bar'
I am surprised by this, I would like my parent class to have a method which has access to a private attribute its children are guaranteed to have. Is there some standard way of solving this problem?
 
     
     
     
    