mardi 29 décembre 2020

Best way to combine different actions in python

Suppose there are n functions defined, each of which represents some action, and functions, whcich represent combinations of these actions:

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()

.....

I don't want to write a separate function for each combination. Which is the best pattern in python to implement this functionality in more elegant way?

Aucun commentaire:

Enregistrer un commentaire