title: Using classes as decorators to decorate a method from another class
body: <p>I'm writing a decorator that I'll use on a <code>class Foo</code> method. Something like this:</p>
  
  <pre class="lang-python prettyprint-override"><code>class decorator(object):
      def __init__(self,func):
          self.func = func
  
      def __call__(self,*args,**kwargs):
          result = self.func(*args,**kwargs)
          # Do stuff
          return result
  
  class Foo(object):
      def __init__(self,arg):
          self.arg = arg
  
      def load(cls,cfg):
          # construct object
          return cls(arg)
  
      @decorator      
      def bar(self,x):
          # run method
          return self
  </code></pre>
  
  <p>When I run the code, it says <code>TypeError: bar() takes exactly 2 arguments (1 given)</code></p>
  
  <p>The method is called like this:</p>
  
  <pre class="lang-python prettyprint-override"><code>def process(cls,cfg,x):
      obj = cls.load(cfg)
          if obj:
              return obj.bar(x)
  </code></pre>
  
  <p>However, if I define the decorator using functions, it seems to work. </p>
  
  <p>What am I doing wrong?</p>