「Python」コールバック(callback)関数を利用するサンプル

書式
変数 = lambda 引数 : 戻り値

サンプルコード

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
def testFunc(i,j):
cft = j(20,18)
return i + "is" + str(cft)
print(testFunc("result",lambda m,m : m - n))
def testFunc(i,j): cft = j(20,18) return i + "is" + str(cft) print(testFunc("result",lambda m,m : m - n))
def testFunc(i,j):
      cft = j(20,18)
      return i + "is" + str(cft)

print(testFunc("result",lambda m,m : m - n)) 

 

実行結果
result is 2

Python

Posted by arkgame