How to append functions to current module from unrelated script in Python -
I have two dragon scripts in different places, I try to import another one in such a way That they first get integrated with one of the globals. It works fine, however when I call functions in other scripts which can get another one, so they find.
Fukpi
def run (): Globe = {} public = {Aksesfile ( "/ path / to / Barkpi" Globe, folk) Karrmodule = globals () currmodule [ "func_in_bar"] = Globe [ "func_in_bar"] func_in_bar () def func_in_foo_A (): print ( "fooA") Def func_in_foo_B (): print ( "fooB") If __name__ == "__main__": run () bar.py
def func_in_bar (): Func_in_foo_A () func_in_foo_B () when If FU is triggered it fails with: NameError: global name 'func_in_foo_A' is not defined
bar.py you need to add an import foo and then reference foo.func_in_foo () , e.t.c Use Alternatively, form: to func_in_foo
Comments
Post a Comment