title: How can I decorate an instance method with a decorator class?
body: <p>Consider this small example:</p>
  
  <pre><code>import datetime as dt
  
  class Timed(object):
      def __init__(self, f):
          self.func = f
  
      def __call__(self, *args, **kwargs):
          start = dt.datetime.now()
          ret = self.func(*args, **kwargs)
          time = dt.datetime.now() - start
          ret["time"] = time
          return ret
  
  class Test(object):
      def __init__(self):
          super(Test, self).__init__()
  
      @Timed
      def decorated(self, *args, **kwargs):
          print(self)
          print(args)
          print(kwargs)
          return dict()
  
      def call_deco(self):
          self.decorated("Hello", world="World")
  
  if __name__ == "__main__":
      t = Test()
      ret = t.call_deco()
  </code></pre>
  
  <p>which prints </p>
  
  <pre><code>Hello
  ()
  {'world': 'World'}
  </code></pre>
  
  <p>Why is the <code>self</code> parameter (which should be the Test obj instance) not passed as first argument to the decorated function <code>decorated</code>?</p>
  
  <p>If I do it manually, like :</p>
  
  <pre><code>def call_deco(self):
      self.decorated(self, "Hello", world="World")
  </code></pre>
  
  <p>it works as expected. But if I must know in advance if a function is decorated or not, it defeats the whole purpose of decorators. What is the pattern to go here, or do I misunderstood something?</p>