title: Python method name with double-underscore is overridden?
body: <p>Take a look at this. 
  Note that class <code>B</code> overrides <code>A</code>'s <code>a()</code> method.</p>
  
  <pre><code>In [1]: class A(object):
     ...:     def __init__(self):
     ...:         self.a()
     ...:     def a(self):
     ...:         print "A.a()"
     ...:         
     ...:         
  
  In [2]: class B(A):
     ...:     def __init__(self):
     ...:         super(B, self).__init__()
     ...:     def a(self):
     ...:         print "B.a()"
     ...:         
     ...:         
  
  In [3]: b = B()
  B.a()
  </code></pre>
  
  <p>No surprises there.</p>
  
  <p>Now, take a look at this.
  Note that the method now being overridden is <code>__a()</code>.</p>
  
  <pre><code>In [7]: class A(object):
     ...:     def __init__(self):
     ...:         self.__a()
     ...:     def __a(self):
     ...:         print "A.__a()"
     ...:         
     ...:         
  
  In [8]: class B(A):
     ...:     def __init__(self):
     ...:         super(B, self).__init__()
     ...:     def __a(self):
     ...:         print "B.__a()"
     ...:         
     ...:         
  
  In [9]: b = B()
  A.__a()
  </code></pre>
  
  <p>This behaviour surprised me.</p>
  
  <p>Can anyone explain why <code>A.__a()</code> is called instead of <code>B.__a()</code>?</p>
  
  <p>Anything <code>__special__</code> about <code>__a</code>?</p>
  
  <p><strong><em>Update</em></strong>:
  After reading Sean's answer I wanted to see if I could override the name mangled method and got this result:</p>
  
  <pre><code>In [11]: class B(A):
     ....:     def __init__(self):
     ....:         super(B, self).__init__()
     ....:     def _A__a(self):
     ....:         print "B._A__a()"
     ....:         
     ....:         
  
  In [12]: b = B()
  B._A__a()
  </code></pre>