title: Public and private methods in Python
body: <p>I am trying to change a public to private parameter inside a Python class. As far as I know, to make it private I need to declare for instance:</p>
  <pre><code>self.__top = None # &lt;-- Instead of self.top = None
  </code></pre>
  <p>However, I cannot figure out how to make a private struct with private properties, such that they are called properly in the public methods.</p>
  <p>For instance:</p>
  <pre><code>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 &gt;= self.size: # ERROR!
              print(&quot;Stack Overflow!&quot;)
              return
  </code></pre>