I have two classes, one is a parent and one a child. For some reason, when I inherit from the parent, not all methods/variables are available. Specifically, trying to access __bar
on Child
returns an error but on Parent
it functions as intended. Really not sure what is going on here. Here is a simplified example:
test.py:
class Parent:
def __init__(self):
self.__bar = 1
class Child(Parent):
def __init__(self):
super().__init__()
print(self.__bar)
Child()
Expected output is just 1
, but the error is:
Traceback (most recent call last):
File "test.py", line 10, in <module>
Child()
File "test.py", line 8, in __init__
print(self.__bar)
AttributeError: 'Child' object has no attribute '_Child__bar'
Although .__bar
is defined in Parent
and I called super().__init__()
to initialize it.