因此,我试图弄清楚如何使这个代码块工作,特别是,如果我要迭代每个函数'func‘,我如何才能调用该函数。
def compare_two_hands(h1, h2):
determinants = [is_flush(h), is_two_pair(h), is_one_pair(h)]
for func in determinants:
if func(h1) or func(h2):
if func(h1) and func(h2):
...
else:
...发布于 2017-04-19 00:53:27
正如您已经编写的那样,调用函数的代码将起作用。唯一的问题是定义list determinants的方式。我假设这三个函数是在同一个名称空间的其他地方定义的。当您在构建列表时引用它们时,只需丢失(h)
def is_flush(h):
...
def is_two_pair(h):
...
def is_one_pair(h):
...
def compare_two_hands(h1, h2):
determinants = [is_flush, is_two_pair, is_one_pair]
# rest of function as you already have ithttps://stackoverflow.com/questions/43484187
复制相似问题