title: Why is the python destructor being called?
body: <p>When I type this into the interpreter, calling 'y' seems to invoke the destructor?</p>
  
  <pre><code>class SmartPhone:
      def __del__(self):
         print "destroyed"
  
  y = SmartPhone()
  y  #prints destroyed, why is that?
  y  #object is still there
  </code></pre>
  
  <p>Here is one run, output does not make sense to me.</p>
  
  <pre><code>C:\Users\z4&gt;python
  Python 2.7.3 (default, Apr 10 2012, 23:31:26) [MSC v.1500 32 bit (Intel)] on win
  32
  Type "help", "copyright", "credits" or "license" for more information.
  &gt;&gt;&gt; class SmartPhone:
  ...     def __del__(self):
  ...        print "destroyed"
  ...
  &gt;&gt;&gt; y = SmartPhone()
  &gt;&gt;&gt; del y
  destroyed
  &gt;&gt;&gt; y = SmartPhone()
  &gt;&gt;&gt; y
  &lt;__main__.SmartPhone instance at 0x01A7CBC0&gt;
  &gt;&gt;&gt; y
  &lt;__main__.SmartPhone instance at 0x01A7CBC0&gt;
  &gt;&gt;&gt; y
  &lt;__main__.SmartPhone instance at 0x01A7CBC0&gt;
  &gt;&gt;&gt; del y
  &gt;&gt;&gt; y = SmartPhone()
  &gt;&gt;&gt; y
  destroyed
  &lt;__main__.SmartPhone instance at 0x01A7CB98&gt;
  &gt;&gt;&gt;
  </code></pre>
  
  <p>and another, calling 'del y' sometimes calls the destructor and sometimes doesn't</p>
  
  <pre><code>C:\Users\z4&gt;python
  Python 2.7.3 (default, Apr 10 2012, 23:31:26) [MSC v.1500 32 bit (Intel)] on win
  32
  Type "help", "copyright", "credits" or "license" for more information.
  &gt;&gt;&gt; class SmartPhone:
  ...     def __del__(self):
  ...             print "destroyed"
  ...
  &gt;&gt;&gt;
  &gt;&gt;&gt; y = SmartPhone()
  &gt;&gt;&gt;
  &gt;&gt;&gt; y
  &lt;__main__.SmartPhone instance at 0x01B6CBE8&gt;
  &gt;&gt;&gt; y
  &lt;__main__.SmartPhone instance at 0x01B6CBE8&gt;
  &gt;&gt;&gt; y
  &lt;__main__.SmartPhone instance at 0x01B6CBE8&gt;
  &gt;&gt;&gt; del y
  &gt;&gt;&gt; y
  Traceback (most recent call last):
    File "&lt;stdin&gt;", line 1, in &lt;module&gt;
  NameError: name 'y' is not defined
  &gt;&gt;&gt; y = SmartPhone()
  &gt;&gt;&gt; y
  destroyed
  &lt;__main__.SmartPhone instance at 0x01B6CC38&gt;
  &gt;&gt;&gt; del y
  &gt;&gt;&gt; y
  Traceback (most recent call last):
    File "&lt;stdin&gt;", line 1, in &lt;module&gt;
  NameError: name 'y' is not defined
  &gt;&gt;&gt;
  </code></pre>