I am trying to change a public to private parametresparameter inside a Python class. As far as I know, to make it private I need to declare for instance:
self.__top = None # <-- In stead of self.top = None
self.__top = None # <-- Instead of self.top = None
However, I cannot figure out how to make a private struct with private properties, such that they are called properly in the public methods.
For instance:
class Stack:
def __init__(self, size=None):
self.__top = None
if size is None: # if size is unset
self.__size = -1
else:
self.__size = size
self.__current_size = -1
def push(self, data):
if self.current_size >= self.size: # ERROR!
print("Stack Overflow!")
return