I want to store functions in a list and then later in a program call those functions from that list.
This works for me, however, I don't know if it is correct :
#example functions, my functions would actually get user input etc.
def func1():
return 2
def func2():
return 3
options = [ func1, func2 ]
#call functions
options[0]()
Is this the proper way to store functions in a list and call it ? Or is there a different, better way to do this?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…