views:

70

answers:

0

Possible Duplicate:
Python decorator makes function forget that it belongs to a class

Is there a way to know that wrapped method belongs to particular class?

In code below:

def guessname(func):
    def this(*args, **kwargs):
        print "myname = %s" % func.__name__
        return func(*args, **kwargs)
    return this

class A(object):
    @guessname
    def B(self):
        pass

a = A()
a.B()

This prints out "myname = B", is there a way to get class name? to get "myname = A.B" ?

If I do "print repr(func)" I get type "function" why not "bound method"?