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
Here is one possible solution:
import types
def setup_1():
print "setup_1"
def setup_2():
print "setup_2"
def setup_3():
print "setup_3"
if __name__ == '__main__':
for name, member in globals().items(): # NB: not iteritems()
if isinstance(member, types.FunctionType) and name.startswith("setup_"):
member()