Python函數可以作爲另一個函數的參數嗎?作爲函數參數的Python函數?
說:
def myfunc(anotherfunc, extraArgs):
# run anotherfunc and also pass the values from extraArgs to it
pass
所以這基本上是兩個問題:
- 是否允許呢?
- 如果是這樣,我該如何使用其他函數內部的函數?我需要使用exec(),eval()或類似的東西嗎?從不需要惹他們。
BTW,extraArgs是anotherfunc參數的列表/元組。
相關:https://stackoverflow.com/questions/47502068/is-there-a-formal-name-for-a-function-that-accepts-a-functions-as-an-argument/47634215#47634215 – alseether 2017-12-04 15:09:42