title: how to reload a Class in python shell?
body: <p>If I import a module defining a class of the same name belonging to a package, it is imported as a Class, not a Module because of the __init__.py of the parent package. See <a href="https://stackoverflow.com/questions/6945592/different-import-results-at-different-directories">different import results at different directories</a> for details. In Python shell or ipython shell, if I do</p>
  
  <p><code>from MyPak import MyMod</code></p>
  
  <p>MyModule is always imported as Class thus I can not reload it (reload() works only for modules). Run </p>
  
  <p><code>from MyPak import MyMod</code></p>
  
  <p>again does not seem to update the Class definition. Could anyone suggest a way to update the class in python shell? </p>
  
  <p>ps. without restarting the python interpreter. </p>
  
  <p><strong>pps</strong>. Just in case you have the code in hand and want to test it: I am actually talking about BioPython, and I am working on Bio.PDB.PDBParser. I have an ipython shell (v0.10) and edit PDBParser.py. Just got no way to reload it in ipython.</p>
  
  <p>so here is what I did:</p>
  
  <pre><code># start ipython v0.10
  import Bio
  from Bio.PDB import PDBParser
  p = PDBParser()
  s = p.get_structure()
  # then I make changes,e.g. simply print some text, in PDBParser.py
  del Bio
  del PDBParser
  del s
  import Bio  # or reload(Bio) without deleting all the objects
  from Bio.PDB import PDBParser
  p = PDBParser()
  s = p.get_structure() # expected output after change not seen :(
  </code></pre>
  
  <p>I could not see the printed text. The changes were not applied somehow. </p>