python (deI) statement and python behavior
<p>When a del statement is issued:</p>

<blockquote>
  <p>del var</p>
</blockquote>

<p>Shouldn't it be removed from the list of known variable and shouldn't the python interpreter spit out "unresolved reference" error?</p>

<p>Or is it simply just deleting the object and leaving the name (var) not pointing anywhere? Why would that kind of behavior be useful? In what cases?</p>

<p>Also I am talking simply about deleting a single variable. Not del list[3] or alike.</p>

<p>note: I am asking if this python's behavior is meant that way. And in what cases, it would be still useful.</p>

<p>EDIT: Charles Addis gave a detailed explanation. I also admit my mistake that I mistook the pycharm behavior as official python's. I am now trying out ipython along with official python interactive shell. Despite this being my mistake, I am glad that I learnt a lot about python variables along with some python debug commands.</p>

<blockquote>
  <p>Shouldn't it be removed from the list of known variable and shouldn't
  the python interpreter spit out "unresolved reference" error?</p>
</blockquote>

<p>This is exactly what happens. Once you <code>del</code> something, the next reference to it will raise <code>NameError</code>.</p>

<blockquote>
  <p>Or is it simply just deleting the object and leaving the name (var)
  not pointing anywhere? Why would that kind of behavior be useful? In
  what cases?</p>
</blockquote>

<p>In Python, things are a bit different. There are no "variables" as you might be used to in other languages.</p>

<p>There is the object space, where data lives - and the namespace, where <em>names</em> live.</p>

<p><em>names</em> are what we normally refer to in other languages as <em>variables</em> but in Python they are simply labels to an object in the data space.</p>

<p>Once the label (name) is removed with <code>del</code>, its simply taking away the label that points to the object. The object (which has the value) remains; unless its not referred to by any other name, in which case Python will then garbage collect it. Names are just lightweight labels that point to objects in the object space, and are the only way we can access those objects.</p>

<p>Here is an example to illustrate this:</p>

<pre><code>&gt;&gt;&gt; x = 5
&gt;&gt;&gt; y = x
&gt;&gt;&gt; del x
&gt;&gt;&gt; y
5
</code></pre>

<p>Now I deleted <code>x</code>, but since <code>y</code> is still pointing to the same object as <code>x</code> (the integer <code>5</code>), it remains and I can access it again; but if I try to access <code>x</code>:</p>

<pre><code>&gt;&gt;&gt; x
Traceback (most recent call last):
  File "&lt;stdin&gt;", line 1, in &lt;module&gt;
NameError: name 'x' is not defined
</code></pre>

python