title: Why is Python 3.x's super() magic?
body: <p>In Python 3.x, <a href="http://docs.python.org/3.3/library/functions.html#super"><code>super()</code></a> can be called without arguments:</p>
  
  <pre class="lang-py prettyprint-override"><code>class A(object):
      def x(self):
           print("Hey now")
  
  class B(A):
      def x(self):
          super().x()
  </code></pre>
  
  <pre class="lang-none prettyprint-override"><code>&gt;&gt;&gt; B().x()
  Hey now
  </code></pre>
  
  <p>In order to make this work, some compile-time magic is performed, one consequence of which is that the following code (which rebinds <code>super</code> to <code>super_</code>) fails:</p>
  
  <pre class="lang-py prettyprint-override"><code>super_ = super
  
  class A(object):
      def x(self):
          print("No flipping")
  
  class B(A):
      def x(self):
          super_().x()
  </code></pre>
  
  <pre class="lang-none prettyprint-override"><code>&gt;&gt;&gt; B().x()
  Traceback (most recent call last):
    File "&lt;stdin&gt;", line 1, in &lt;module&gt;
    File "&lt;stdin&gt;", line 3, in x
  RuntimeError: super(): __class__ cell not found
  </code></pre>
  
  <p>Why is <code>super()</code> unable to resolve the superclass at runtime without assistance from the compiler? Are there practical situations in which this behaviour, or the underlying reason for it, could bite an unwary programmer?</p>
  
  <p>... and, as a side question: are there any other examples in Python of functions, methods etc. which can be broken by rebinding them to a different name?</p>