Decorating python class methods, how do I pass the instance to the decorator?
<p>This is python 2.5, it's GAE too not that it matters. </p>

<p>I have the following code, I'm decorating the foo() method in bar, using the dec_check class as a decorator.</p>

<pre><code>class dec_check(object):

  def __init__(self, f):
    self.func = f 

  def __call__(self):
    print 'In auth_check.__init__()'
    self.func()

class bar(object):

  @dec_check
  def foo(self):
    print 'In bar.foo()'

b = bar()
b.foo()
</code></pre>

<p>When executing this I was hoping to see:</p>

<pre><code>In dec_check.__init__()
In bar.foo()
</code></pre>

<p>But I'm getting "TypeError: foo() takes exactly 1 argument (0 given)" as foo() being an object method takes <code>self</code> as an argument. I'm guessing problem is that the instance of <code>bar</code> doesn't actually exist when I'm executing the decorator code. So how do I pass an instance of <code>bar</code> to the decorator class?  </p>
