Functions are objects in Python.
If you refer to them just by their name (without the parentheses, which do actually call the function!), you refer to the underlying function objects. You can re-bind them, inspect them .. or store a reference to them in a list.
mylist = [test_func_1,test_func_2,..]
At this point, none of the functions has been executed. You can then use random.choice
to pick a function from the list and invoke it using ()
:
mylist[0]()
calls the first function in the list
random.choice(mylist)()
calls a random function