title: Python decorator makes function forget that it belongs to a class
body: <p>I am trying to write a decorator to do logging:</p>
  
  <pre><code>def logger(myFunc):
      def new(*args, **keyargs):
          print 'Entering %s.%s' % (myFunc.im_class.__name__, myFunc.__name__)
          return myFunc(*args, **keyargs)
  
      return new
  
  class C(object):
      @logger
      def f():
          pass
  
  C().f()
  </code></pre>
  
  <p>I would like this to print:</p>
  
  <pre><code>Entering C.f
  </code></pre>
  
  <p>but instead I get this error message:</p>
  
  <pre><code>AttributeError: 'function' object has no attribute 'im_class'
  </code></pre>
  
  <p>Presumably this is something to do with the scope of 'myFunc' inside 'logger', but I've no idea what.</p>