title: Is it somehow possible to *live* modify Python code (like in Lisp or Erlang)
body: <p>I was wondering if it is somehow possible to modify Python code live, while keeping all state of instantiated objects and methods, like I <em>think</em> is possible in Lisp or Erlang (*) ?</p>
  
  <p>Say, I have an active Python sessions, where I instantiated the <code>foo</code> class from a self-written module:</p>
  
  <pre><code>class foo():
     @classmethod
     def do_something(self):
         print "this is good"
  </code></pre>
  
  <p>Python command line:</p>
  
  <pre><code>&gt;&gt;&gt; f =foo()
  &gt;&gt;&gt; f.do_something()
  </code></pre>
  
  <p>Now, I would like to change the print statement into something else (e.g. <code>print "this is better"</code>). If I edit my module file to do so, and reload it, I have to re-instantiate the <code>f</code> object. Is there a way to be able to just call <code>f.do_something()</code> again without having to call <code>f=foo()</code> first?</p>
  
  <p>So, I have to do this:</p>
  
  <pre><code>&gt;&gt;&gt; reload my_module
  &gt;&gt;&gt; f =foo()
  &gt;&gt;&gt; f.do_something() # with changed print statement
  </code></pre>
  
  <p>But I want to do this:</p>
  
  <pre><code>&gt;&gt;&gt; reload my_module
  &gt;&gt;&gt; f.do_something() # with changed print statement
  </code></pre>
  
  <p>(*) I am basing this statement on the <a href="http://www.youtube.com/watch?v=uKfKtXYLG78" rel="nofollow">cool Erlang movie</a> and this fragment from <a href="http://www.gigamonkeys.com/book/lather-rinse-repeat-a-tour-of-the-repl.html" rel="nofollow">Practical Common Lisp</a>: '<em>When the bug manifested in the wild--100 million miles away from Earth--the team was able <strong>to diagnose and fix the running code</strong>, allowing the experiments to complete.</em>'</p>
  
  <p><strong>Edit:</strong> I've been thinking a bit more about this and maybe what I want is inherently flawed for applying to OO (i.e., what about the state of the class and methods). I think Erlang allows this because, as far as I recall, it is more about separate communicating objects, so live updating the code of an object makes more sense. I am not sure though, so still open for answers.</p>
  
  <p><strong>Edit2:</strong> Maybe the best way to describe what I want is recapitulate what I said in a comment in a post below: "When called, the methods just have to point to the new method definitions/locations."</p>