什么是正确的语法?
编程尝试
class Foo:
def hello(self):
print "Hello cruel world!"
def greet_first(self, f):
self.hello()
return lambda *args, **kwargs: f(*args, **kwargs)
@greet_first
def goodbye(self, concat):
print "Goodbye {0}".format(concat)
if __name__=='__main__':
bar = Foo()
bar.goodbye(' and thanks for all the fish')
调试
Traceback (most recent call last):
File "prog.py", line 1, in <module>
class Foo:
File "prog.py", line 9, in Foo
@greet_first
TypeError: greet_first() takes exactly 2 arguments (1 given)