title: Reload a whole package structure in Python
body: <p>I'm working within Maya. What i need is to import a custom package and completely reload it inlcuding all subpackages and modules. Mainly because i want Maya autocompletes for me the module path while im writing. For example i have this kind of package structure</p>
  
  <pre><code>root (package)
      subpackage1 (package)
          __init__.py (module)
          a.py (module)
          b.py (module)
  
      subpackage2 (package)
          c.py (module)
          d.py (module)
          e.py (module)
  </code></pre>
  
  <p>What i did on <strong>__init__.py</strong> files is to import all submodules and one by one to reload them there</p>
  
  <p><strong>ex: root.subpackage1.__init__.py</strong></p>
  
  <pre><code>import a
  import b
  reload(a)
  reload(b)
  </code></pre>
  
  <p>This is very tedious, and thus i suppose there is a much better way to import and reload all the structure</p>
  
  <p>When i import the package the first time the whole structure is load into memory.</p>
  
  <pre><code>import root
  reload(root)
  root.subpackage1.a.my_function()
  </code></pre>
  
  <p>so lets suppose now i update a.py file and add a function named my_test. I need again to reload all package structure to be able to evaluate it like this.</p>
  
  <pre><code>root.subpackage1.a.my_test()
  </code></pre>
  
  <p>whitout doing this...</p>
  
  <pre><code>from root.subpackage import a
  reload(a)
  a.my_test()
  </code></pre>
  
  <p>I wall everything to be reloaded when i import and reload <strong>root</strong>
  whats the best practice to do this?
  Thanks in advance.</p>