class Queue:
def __init__(self):
self.__part_list = []
def put(self, elem):
self.__part_list.append(elem)
print(self.__part_list)
def get(self):
val = self.__part_list[0]
del self.__part_list[0]
return val
def isempty(self):
if len(self.__part_list) == 0:
return True
else:
return False
class SuperQueue(Queue):
def __init__(self):
Queue.__init__(self)
def print_list(self):
print(self.__part_list)
que2 = Queue()
que = SuperQueue()
que.put(1)
que.put("dog")
que.put(False)
que.print_list()
AttributeError: 'SuperQueue' object has no attribute '_SuperQueue__part_list'
I can print part_list from within the superclass but not from within the subclass. I thought the subclass would inherit the list from the superclass but I cannot call it.