title: Getting parent private or protected values from the child class
body: <p>Well, I have almost the same <a href="https://stackoverflow.com/questions/4935587/python-getting-baseclass-values-from-derived-class">question</a>, except one detail: I need to get private values of the base class. Code:</p>
  <pre><code>class Parent(object):
      def __init__(self):
          self.__field = 13
  
  class Child(Parent):
      def ChildMethodWhichUsingParentField(self):
          return self.__field
  
  c = Child()
  c.ChildMethodWhichUsingParentField()
  </code></pre>
  <p>Interpreter output:</p>
  <pre class="lang-none prettyprint-override"><code>Traceback (most recent call last):
    File &quot;foo.py&quot;, line 20, in &lt;module&gt;
      c.ChildMethodWhichUsingParentField()
    File &quot;foo.py&quot;, line 16, in ChildMethodWhichUsingParentField
      return self.__field
  AttributeError: 'Child' object has no attribute '_Child__field'
  </code></pre>
  <p>The problem is that interpreter tries to get <code>_Child__field</code> when I need <code>_Parent__field</code>. I can get this value using <code>@property</code>, but it will break the encapsulation. Also I can solve this problem writing <code>self._Parent__field</code> but this is ugly and obviously bad code. Is there any other ways?</p>