【发布时间】:2020-12-29 22:09:54
【问题描述】:
假设定义了n函数,每个函数代表一些动作,而函数代表这些动作的组合:
def all_actions():
action1()
action2()
action3()
...
actionN()
def combination_of_1_and_2():
action1()
action2()
def combination_of_1_and_3():
action1()
action3()
def combination_of_1_2_and_3():
action1()
action2()
action3()
.....
如何在不为每个组合编写单独的函数的情况下在 Python 中实现此功能?
更新
如果您将此问题视为基于意见的问题,则必须将best practices 上的任何问题视为基于意见的问题并且不允许。但是定义说:Coding best practices are a set of informal rules that the software development community employ to help improve the quality of software.,这意味着它们都是非正式的并且基于社区意见。
【问题讨论】:
标签: python function design-patterns functional-programming