【发布时间】:2019-02-09 03:34:54
【问题描述】:
我有一个类,其中有一个名为decorator_func 的函数和另一个名为name_me 的函数。如何用类中的其他函数装饰name_me 函数?
这是我目前尝试过的:
class Test :
def decorator_func(fun):
def disp_fun(name):
return ("hello there ,") + fun(name)
return disp_fun
@decorator_func
def name_me(name):
return name
print name_me("abhi")
obj = Test()
obj.decorator_func()
如何消除此错误?
【问题讨论】:
标签: python oop python-decorators