title: How to make global imports from a function?
body: <p>I fear that this is a messy way to approach the problem but... </p>
  
  <p>let's say that I want to make some imports in Python based on some conditions.</p>
  
  <p>For this reason I want to write a function:</p>
  
  <pre><code>def conditional_import_modules(test):
      if test == 'foo':
          import onemodule, anothermodule
      elif test == 'bar':
          import thirdmodule, and_another_module
      else:
          import all_the_other_modules
  </code></pre>
  
  <p>Now how can I have the imported modules globally available?</p>
  
  <p>For example:</p>
  
  <pre><code>conditional_import_modules(test='bar')
  thirdmodule.myfunction()
  </code></pre>