How to append functions to current module from unrelated script in Python
Question: I have two python scripts in different locations. I try to import the
functions of the second one in such a way that they are integrated with the
globals of the first one. That works fine. However when I call functions in
the first script from the second one they cant be found.

foo.py

    
    
    def run():
        glob = {}
        loc = {}
        execfile("/path/to/bar.py", glob, loc)
        currmodule = globals() 
        currmodule["func_in_bar"] = glob["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 foo is run it fails with: `NameError: global name 'func_in_foo_A' is not
defined`


Answer: In `bar.py` you need to add an `import foo` and then reference
`foo.func_in_foo()`, etc.

Alternatively, use the form: `from foo import func_in_foo`

