Execute all functions in a file without explicitly calling them in Python

def some_magic():
    import a
    for i in dir(a):
        item = getattr(a,i)
        if callable(item):
            item()

if __name__ == '__main__':
    some_magic()
#!/usr/local/bin/python3
import inspect
import sys


def f1():
    print("f1")


def f2():
    print("f2")


def some_magic(mod):
    all_functions = inspect.getmembers(mod, inspect.isfunction)
    for key, value in all_functions:
        if str(inspect.signature(value)) == "()":
            value()

if __name__ == '__main__':
    some_magic(sys.modules[__name__])
members = inspect.getmembers(self)

for key, value in members:

    if key.startswith("run_"):
        if callable(value):
            if value():
                break

References
https://stackoverflow.com/questions/28643534/is-there-a-way-in-python-to-execute-all-functions-in-a-file-without-explicitly-c