title: Python 2.7 inheritance from metaclasses
body: <p>I've got a toy python example where defining an inline metaclass as a function behaves differently than defining it as a class, and I'm trying to understand why:</p>
  
  <pre><code>&gt;&gt;&gt; class Test(object):
  ...     def __metaclass__(name, bases, nmspc):
  ...         cls = type(name, bases, nmspc)
  ...         def __init__(self, field, *args, **kwargs):
  ...             print "making " + field
  ...             super(cls, self).__init__()
  ...         cls.__init__ = __init__
  ...         return cls
  ... 
  &gt;&gt;&gt; t = Test('lol')
  making lol
  &gt;&gt;&gt; class Test2(Test): pass
  ... 
  &gt;&gt;&gt; t = Test2('lol')
  making lol
  </code></pre>
  
  <p>Versus:</p>
  
  <pre><code>&gt;&gt;&gt; class Test(object):
  ...      class __metaclass__(type):
  ...              def __init__(cls, name, bases, nmspc):
  ...                      type.__init__(cls, name, bases, nmspc)
  ...                      def __init__(self, field, *args, **kwargs):
  ...                              print "making " + field
  ...                              super(cls, self).__init__()
  ...                      cls.__init__ = __init__
  ... 
  &gt;&gt;&gt; t = Test('lol')
  making lol
  &gt;&gt;&gt; class Test2(Test): pass
  ... 
  &gt;&gt;&gt; t2 = Test2('lol')
  making lol
  Traceback (most recent call last):
    File "&lt;stdin&gt;", line 1, in &lt;module&gt;
    File "&lt;stdin&gt;", line 7, in __init__
  TypeError: __init__() takes at least 2 arguments (1 given)
  </code></pre>
  
  <p>So, what exactly is different between defining a class vs defining a function? They both end up returning a class through slightly different ways, since the modified cls.__init__ gets inherited one way but not the other.</p>
  
  <p>I also checked similar construction by making a function and class declaration outside, and I get the same behavior.</p>