title: Insert variable into global namespace from within a function?
body: <p>Is it possible to add an object to the global namespace, for example, by using <code>globals()</code> or <code>dir()</code>?</p>
  <pre class="lang-py prettyprint-override"><code>def insert_into_global_namespace(var_name, value):
      globals()[var_name] = value
  
  
  insert_into_global_namespace('my_obj', 'an object')
  print(f'my_obj = {my_obj}')
  </code></pre>
  <p>But this only works in the current module.</p>