When you decorate a method, it is not bound yet to the class, and therefor doesn't have the im_class attribute yet. I looking for a way to get the information about the class inside the decorator. I tried this:
import types
def decorator(method):
    def set_signal(self, name, value):
        print name
        if name == 'im_class':
            print "I got the class"
    method.__setattr__ = types.MethodType(set_signal, method)
    return method
class Test(object):
    @decorator
    def bar(self, foo):
        print foo
But it doesn't print anything.
I can imagine doing this:
class Test(object):
    @decorator(klass=Test)
    def bar(self, foo):
        print foo
But if I can avoid it, it would make my day.
 
     
     
     
    