title: python how to check if a module exists without importing it
body: <p>I need to check if module exists (without checking if their import modules exists), import the module to check if it exists is a bad idea because:</p>
  
  <p><strong>foo/module_A.py:</strong></p>
  
  <pre><code>import invalid_module_asdfghjkl
  
  
  class ClassA:
      pass
  </code></pre>
  
  <p><strong>foo/module_B.py:</strong></p>
  
  <pre><code>try:
      __import__('foo.module_A')
  except ImportError, e:
      &gt;&gt;&gt; No module named invalid_module_asdfghjkl
  </code></pre>
  
  <p>So, <strong>My module exists</strong>, but not one of their imported modules, how can I check IF MY MODULE EXISTS when it has invalid imports?</p>