title: How to wrap the methods of class A as the methods of class B in Python?
body: <p>I have many class like <code>SpaceA</code>, <code>SpaceB</code>, <code>SpaceC</code>, and so on. These classes have some similar methods, for example <code>method_1</code>, <code>method_2</code>, ..., <code>method_n</code>. But for specific class, it maybe not been implement all the <code>method_i</code>. The following is an example:</p>
  <pre><code>import numpy as np
  
  class SpaceA(object):
      def method_1(self, array, b, c=None):
          print('method_1', array, b, c)
  
      def method_2(self, array, b, c=None):
          print('method_2', array, b, c)
  
      def method_3(self, array, b, c=None):
          print('method_2', array, b, c)
      ... # many methods
  
  class SpaceB(object):
      ...
      def method_1(self, array, b, c=None):
          print('method_1', array, b, c)
  
      def method_2(self, array, b, c=None):
          print('method_2', array, b, c)
  
      def method_3(self, array, b, c=None):
          print('method_2', array, b, c)
      ... # many methods
  </code></pre>
  <p>I want to define another class named <code>Function</code> like following:</p>
  <pre><code>class Function(np.ndarray):
      def __new__(cls, space, array=None):
          if array is None:
              self = np.zeros(100).view(cls)
          else:
              self = array.view(cls)
          self.space = space
          return self
  
      def method_1(self, b, c=None):
          return self.space.method_1(self, b, c=c)
  
      def method_2(self, b, c=None):
          return self.space.method_2(self, b, c=c)
  
      ... # many wrapper
  
  A = SpaceA()
  B = SpaceB()
  
  fA = Function(A)
  fB = Function(B)
  </code></pre>
  <p>I want to automatically wrap every <code>method_i</code> of a specific class into <code>Function</code> class, is it possible? and how?</p>
  <p>Maybe <code>__metaclass__</code> can solve my problem, but I don't make it success.</p>