title: How to operate decorator on derived python class?
body: <p>I would like to use a decorator to do something with a derived class (e.g. register the class or something). Here is my code:</p>
  
  <pre><code>from functools import wraps
  
  class Basic(object):
      def __init__(self):
          print "Basic::init"
  
  def myDeco(name):
      # define the decorator function that acts on the actual class definition
      def __decorator(myclass):
  
          # do something here with the information
          print name, myclass
  
          # do the wrapping of the class 
          @wraps(myclass)
          def __wrapper(*args, **kwargs):
              return myclass( *args, **kwargs)
  
          # return the actual wrapper here
          return __wrapper
  
      # return the decorator to act on the class definition
      return __decorator
  
  @myDeco("test")
  class Derived(Basic):
      def __init__(self):
          super(Derived, self).__init__()
          print "Derived::init"
  
  
  instance = Derived()
  </code></pre>
  
  <p>which gives the following error:</p>
  
  <pre><code>TypeError: must be type, not function
  </code></pre>
  
  <p>when the <code>super</code> method in <code>Derived</code> is called. I assume the variable <code>Derived</code> is no longer a <code>type</code>, but the function <code>__decorator</code> actually. </p>
  
  <p>How do I need to change the decorator (and ONLY the decorator) to fix this problem? </p>