title: How to import all submodules?
body: <p>I have a directory structure as follows:</p>
  
  <pre><code>| main.py
  | scripts
  |--| __init__.py
     | script1.py
     | script2.py
     | script3.py
  </code></pre>
  
  <p>From <code>main.py</code>, the module <code>scripts</code> is imported. I tried using <code>pkgutils.walk_packages</code> in combination with <code>__all__</code>, but using that, I can only import all the submodules directly under <code>main</code> using <code>from scripts import *</code>. I would like to get them all under <code>scripts</code>. What would be the cleanest way to import all the submodules of <code>scripts</code> so that I could access <code>scripts.script1</code> from <code>main</code>?</p>
  
  <p>EDIT: I am sorry that I was a bit vague. I would like to import the submodules on run-time without specifying them explicitly in <code>__init__.py</code>. I can use <code>pkgutils.walk_packages</code> to get the submodule names (unless someone knows of a better way), but I am not sure of the cleanest way to use these names (or maybe the ImpImporters that <code>walk_packages</code> returns?) to import them.</p>