How to append functions to current module from unrelated script in Python
<p>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.</p>

<p>foo.py</p>

<pre><code>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()
</code></pre>

<p>bar.py</p>

<pre><code>def func_in_bar():
    func_in_foo_A()
    func_in_foo_B()
</code></pre>

<p>When foo is run it fails with: <code>NameError: global name 'func_in_foo_A' is not defined</code></p>
