python3中遇到问题!
>>> def f1(x):
return x*2
>>> def new_fn(f):
def fn(x):
print('call'+f._name_+'()')
return f(x)
return fn
>>> f1=new_fn(f1)
>>> print(f1(5))
Traceback (most recent call last):
File "<pyshell#10>", line 1, in <module>
print(f1(5))
File "<pyshell#8>", line 3, in fn
print('call'+f._name_+'()')
AttributeError: 'function' object has no attribute '_name_'