>>> class test(object):
def simplewrap(self, func):
def wrapper(*args, **kwds):
self.print('----start----')
func(args, kwds)
self.print('----end----')
return wrapper
def print(self, string):
print('In function print')
print(string)
print('Finish')
@self.simplewrap
def wraped(self):
print('In function print')
Traceback (most recent call last):
File "<pyshell#24>", line 1, in <module>
class test(object):
File "<pyshell#24>", line 14, in test
@self.simplewrap
NameError: name 'self' is not defined
NameError: name 'self' is not defined
- 写回答
- 好问题 0 提建议
- 关注问题
- 邀请回答
-