title: Keep object reference when class is deleted?
body: <p>I have a class <code>Foo</code> which is instantiated an indefinite number of times during my program sequence. Like so:</p>
  
  <pre><code>def main():
      f = Foo()
      while f.run():
          del f
          f = Foo()
  </code></pre>
  
  <p>with <code>run()</code> being a method that runs an decisive condition for keeping the program alive.</p>
  
  <p>Now, my <code>Foo</code> class creates on its <code>__init__</code> method two objects <code>a</code> and <code>b</code>:</p>
  
  <p><strong>Foo class</strong></p>
  
  <pre><code>class Foo:
      def __init__(self):
          a = A()
          b = B(a.var)
  </code></pre>
  
  <p>I'm looking for a way to <code>a</code> being declared <strong>only at the first <code>Foo</code> instantiation</strong> and use that same first-instantiated <code>a</code> at the other <code>Foo</code> instantiations.</p>
  
  <p>Problem arises because <code>b</code> depends on <code>a</code>. I thought about a couple solutions - from playing with <code>__new__</code> and <code>__init__</code> to override <code>__del__</code> and global variable as cache - but none of them worked.</p>
  
  <p><strong>note</strong>: <code>A</code> needs to be at the same module as <code>Foo</code></p>