title: Object deletes reference to self
body: <p>Does Python interpreter gracefully handles cases where an object instance deletes the last reference to itself?</p>
  
  <p>Consider the following (admittedly useless) module:</p>
  
  <pre><code>all_instances = []
  
  class A(object):
      def __init__(self):
          global all_instances
          all_instances.append(self)
  
      def delete_me(self):
          global all_instances
          self.context = "I'm still here"
          all_instances.remove(self)
          print self.context
  </code></pre>
  
  <p>and now the usage:</p>
  
  <pre><code>import the_module
  a = the_module.A()
  the_deletion_func = a.delete_me
  del a
  the_deletion_func()
  </code></pre>
  
  <p>This would still print <code>I'm still here</code>, but is there a race condition with Python's garbage collector which is about to collect the object instance?<br>Does the reference to the object's function save the day?<br>Does the interpreter keep references to the object whose code it is currently executing until it finishes?</p>