【发布时间】:2014-10-31 16:18:06
【问题描述】:
我希望将一个函数以及一个命名参数传递给另一个函数。这类似于the question asked here,只是它不处理命名参数。在 cmets 中提出了一个问题,但没有回复。
例子:
def printPath(path, displayNumber = False):
pass
def explore(path, function, *args):
contents = function(*args)
print explore(path, printPath, path, displayNumber = False)
这给出了错误:
TypeError: explore() got an unexpected keyword argument 'displayNumber'
【问题讨论】:
-
一个已经讨论过的更相关的问题 - stackoverflow.com/questions/5940180/…
标签: python