This does not give the objects functions directly, but you need to use eval, I check the solution with vars () to get rid of eval:
def setup_1():
print('setup_1')
def setup_2():
print('setup_2')
def setup_3():
print('setup_3')
if __name__ == '__main__':
[eval(func+'()') for func in dir() if func.startswith('setup_')]
Ok, here is the version with vars ():
def setup_1():
print('setup_1')
def setup_2():
print('setup_2')
def setup_3():
print('setup_3')
if __name__ == '__main__':
[vars()[func]() for func in dir() if func.startswith('setup_')]
source
share