fn(x)中的参数x从哪里来呢?
如题,return fn,这时g1指向了fn,有没进行了fn(x)的调用?如果进行了调用,貌似并没有传到参数给x呀。
>>> def f1(x):
... return x*2
...
>>> def new_fn(f):
... def fn(x):
... print 'call'+f._name_+'()'
... return f(x)
... return fn
...
>>> g1=new_fn(f1)
>>> print g1(5)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "<stdin>", line 3, in fn
AttributeError: 'function' object has no attribute '_name_'