jeudi 30 juillet 2020

chosing a function without if statement in python

Imagine having 200 functions, which represent 200 ways to solve a problem or calculate something like

def A():
   ...
   
def B():
   ...
.
.
.

and the method will be chosen as an input argument, meaning the user decides which method to use, giving this as an argument while running the program like "A" for function/method A. how to chose that function without if-checking the name of every single function in python.

Aucun commentaire:

Enregistrer un commentaire