title: Can not call dynamically imported python modules
body: <p>I can not access dynamically imported modules in python.</p>
  
  <p>Either my call syntax is wrong or the import does not work properly.</p>
  
  <p>There are many topics on stackoverflow.com which deal with dynamic import in
  Python. Yet, I adopted the code from this site: <a href="https://www.daniweb.com/software-development/python/code/238387/really-simple-plugins-loader-import-all-modules-in-a-folder-in-one-swoop" rel="nofollow">https://www.daniweb.com/software-development/python/code/238387/really-simple-plugins-loader-import-all-modules-in-a-folder-in-one-swoop</a></p>
  
  <p><strong>It automagically imports all modules present in a folder and returns a dictionary.</strong></p>
  
  <p>Code:</p>
  
  <pre><code>import glob, imp
  from os.path import join, basename, splitext
  
  def importPluginModulesIn(dir):
      return dict( _load(path) for path in glob.glob(join(dir,'[!_]*.py')) )
  def _load(path):
      name, ext = splitext(basename(path))
      return name, imp.load_source(name, path)
  
  modules = importPluginModulesIn('modules_folder')
  print modules
  </code></pre>
  
  <p>The output suggests successful import:</p>
  
  <pre><code>{'test_function': &lt;module 'test_function' from 'modules_folder/test_function.py'&gt;}
  </code></pre>
  
  <p><strong>Yet, the suggested access method, yields no response at all <em>(should print: "Test complete.")</em>:</strong></p>
  
  <pre><code>modules['test_function'].__name__
  </code></pre>
  
  <p>Anyone any suggestions how to fix this?
  Thanks!</p>
  
  <p>EDIT:
  Martijn Pieters made me aware I was actually mistaking module and function.
  (See comments below.)
  Now my question is how to actually, within the frame of my code, call test_function, embedded in the module
  test_function.py?</p>
  
  <p>EDIT2:
  Content of test_function.py in modules_folder:</p>
  
  <pre><code>import time
  
  def test_function():  
      print('Start.')
      time.sleep(1)    
      print('Test complete.')
  </code></pre>