0
我寫的什麼我嘗試做一個簡單的例子:應用測試還原(調用FUNC返回FUNC),以獲得在python的抽象(功能)
class Test:
@staticmethod
def mul(x,y):
return x*y
FUNC1 = staticmethod(lambda y: Test.mul(y,2))
FUNC2 = staticmethod(lambda y: staticmethod(lambda x: Test.mul(y,x)))
print Test.FUNC1(2)
print Test.FUNC2(2)(3)
print Test.FUNC2(2)(3)
TypeError: 'staticmethod' object is not callable
我期待第二線打印6(如3 * 2),如何做到這一點?
Test.FUNC1(2)正常工作,其Test.FUNC2是行不通......這個答案是不相關的... –
@OfekRon哦,我在這兩個例子貼錯標籤的功能。現在修好了......你對FUNC1沒有任何問題,對吧? –