In python I have many functions likes the ones below. I would like to run all the functions whose name matches setup_* without having to explicitly call them fr
You can use locals()
L = locals()
for k in L:
if hasattr(L[k], '__call__') and k.startswith('setup'):
L[k]()
Of course you'll want to make sure that your function names don't appear elsewhere in locals.
In addition, you could also do something like this because functions are first class objects (note the function names are not strings):
setupfunctions = [setup_1, setup_2, setup_3, myotherfunciton]
for f in setupfunctions:
f()