My module what know who call its function, like
a.py
importlib.import_module("b")
b.b()
b.py
def b():
importlib.import_module("c")
print(parent_module)
c.c()
c.py
import c
def c():
print(parent_module)
I want b()
print module a, and c()
print b
I tried this func
def get_parent_name():
print('get parent module')
print(os.path.splitext(os.path.basename(getframeinfo(stack()[-1][0]).filename))[0])
but it can only get the toppest module, like
b()
print a
and c()
print a