title: Adding to local namespace in Python?
body: <p>Is there a way in Python to add to the locals name-space by calling a function without explicitly assigning variables locally?</p>
  
  <p>Something like the following for example (which of course doesn't work, because locals() return a copy of the local name-space) where the print statement would print '1'.</p>
  
  <pre><code>def A():
    B(locals())
    print x
  
  def B(d):
    d['x'] = 1
  </code></pre>