This questions is related global-scope of python.
There are have two files below.
fileA.py
import pprint
pprint.pprint(globals())
fileB.py
import fileA
def global_funcB():
return "global_funcB"
When I run python fileB.py
. The globals() of fileA.py only contains fileA's content.
Is that possible to get address of global_funcB
in fileB.py from fileA.py? So far, I only can do this from fileB.py.
Note: for my purpose, there is no way to import fileB from fileA.py
[Edit]
Let me describe my purpose clearly.
loader.py
class loader(object):
def __init__(self, module):
print(dir(module))
builder.py + class function
import loader
class someobj(object):
def somefunc(self):
pass
loader.loader(someobj)
If I passing some module/class from fileB to build fileA, then it's possible to fetch function of fileB.
However, if the function in builder.py is globally.
builder.py + global function
import loader
def someglobalfunc(self):
pass
loader.loader(???)
I have no idea how to pass globals() as a module/class to another file.