I wanted to define the api in superclass A
, and use the data
property directly in subclass B
, but it is trying to access the __data
in A
apprently.
I was expecting to see [4, 5]
in output
class A(object):
def __init__(self):
self.__data = [1, 2, 3]
@property
def data(self):
return self.__data
class B(A):
def __init__(self):
self.__data = [4,5]
b = B()
print b.data
# AttributeError: 'B' object has no attribute '_A__data'