 <p>You should really be storing those names on an object stored in a global and not as global variables. But you asked how to do it and so here is how:</p> <p>Using <a href="http://stackoverflow.com/questions/7027848/getting-corresponding-module-from-function">Getting corresponding module from function</a> with a <code>for</code> loop and <code>setattr</code> as modules do not support dictionary operations and it is possible to write the function as:</p> <pre><code>import sys def load_inmemory(): module = sys.modules[load_inmemory.__module__] for k, v in load237(fpath)[0].items(): setattr(module, k, v) load_inmemory() print x </code></pre> <p>I tested the following:</p> <pre><code>import sys def func(): module = sys.modules[func.__module__] for k,v in {'x':4}.items(): setattr(module, k, v) func() print x </code></pre> <p>Prints <code>4</code>. Tested in Python 2.7.3.</p>