title: Apply a method to an object of another class
body: <p>Given two non-related classes A and B, how to call <code>A.method</code> with an object of B as <code>self</code>?</p>
  
  <pre><code>class A:
      def __init__(self, x):
          self.x = x
  
      def print_x(self):
          print self.x
  
  class B:
      def __init__(self, x):
          self.x = x
  
  a = A('spam')
  b = B('eggs')
  
  a.print_x() #&lt;-- spam
  &lt;magic&gt;(A.print_x, b) #&lt;-- 'eggs'
  </code></pre>