title: python importlib dynamic reload does not work
body: <p>I am implementing tool that allow plugins by other people.
  Inside each module there should be a class with the same name as the module.
  All the examples in the web seems only working on known module name.<br />
  But in my case, the module name must be a parameter.
  Also I would like to allow those plugin developers to debug with my tool so that they can make online changes to their plugins.<br />
  I use python importlib.reload for this purpose.
  Unfortunately I have not succeeded in making my code work.<br />
  My code segment is as follows.</p>
  <pre><code>from importlib import reload
  
  def pluginReload(pluginName, *initialArgs): 
      pluginModule = sys.modules[pluginName]
      pluginModuleX = reload(pluginModule)
      pluginModule = sys.modules[pluginName]
      claasObj = getattr(pluginModule, pluginName)
      pluginInstance = classObj(*initialArgs)
  
      return pluginInstance 
  </code></pre>
  <p>Here is another try.</p>
  <pre><code>def pluginReload(pluginName): 
      pluginModule = sys.modules[pluginName]
      pluginModule = reload(pluginModule)
  </code></pre>
  <p>I have experimented with various combination of the above code, but none makes the reload work to reflect change in module pluginName.
  I have tried pluginModule and pluginModuleX.</p>
  <p>I even tried the very simple example script as follows:</p>
  <pre><code>from importlib import import_module, reload 
  import reloadTest 
  aReload = reloadTest.at()
  
  print (&quot;getTest 1: &quot;, aReload.getTest())
  print (&quot;sys.modules 1: &quot;, sys.modules.keys())
  
  xx = input()
  print (&quot;xx--&gt; &quot;, xx)
  
  aReloadModule = sys.modules['reloadTest']
  
  sys.modules['reloadTest'] = reload(aReloadModule)
  print (&quot;sys.modules 2: &quot;, sys.modules.keys())
  print (&quot;getTest 2: &quot;, aReload.getTest()) 
  
  sys.exit(-1)
  </code></pre>
  <p>which imports the following module reloadTest.</p>
  <pre><code>class at: 
      def __init__(self): 
          self.x = 1
  
      def getTest(self): 
          print (&quot;hello world 5&quot;)
          return self.x 
  </code></pre>
  <p>But this simple code also did not work.
  Any comments and suggestions will be appreciated.</p>
  <p>Thanks</p>
  <p>Farn</p>