title: How to know if object gets deleted in Python
body: <p>I have an object in the heap and a reference to it. There are certain circumstances in which the object gets deleted but the reference that points to its location doesn't know that. How can I check if there is real data in the heap?</p>
  
  <p>For example:</p>
  
  <pre><code>from PySide import *
  a = QProgressBar()
  b = QProgressBar()
  self.setIndexWidget(index,a)
  self.setIndexWidget(index,b)
  </code></pre>
  
  <p>Then the <code>a</code> object gets deleted but <code>print(a)</code> returns a valid address. However if you try <code>a.value()</code> - runtime error occurs (C++ object already deleted).</p>
  
  <p><code>a is None</code> returns <code>False</code>.</p>