def deco(clazz):
def dec(fn):
print clazz,fn
return fn
return dec
class Foo(object):
@deco(Foo)
def Bar():
print "bar"
Traceback (most recent call last):
File "<pyshell#12>", line 1, in <module>
class Foo(object):
File "<pyshell#12>", line 2, in Foo
@deco(Foo)
NameError: name 'Foo' is not defined
import traceback
def deco():
clazz = traceback.extract_stack()[1][2]
def dec(fn):
print clazz,fn
return fn
return dec
class Foo(object):
@deco()
def Bar():
print "bar"