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>

<p>The "del" removes the name from the current namespace. If the underlying object has its reference count drop to zero, then the object itself is freed.</p>

<pre><code>&gt;&gt;&gt; import sys
&gt;&gt;&gt; x = 123456
&gt;&gt;&gt; y = x               # create a second reference to the number
&gt;&gt;&gt; dir()               # known variables include "x" and "y"
['__builtins__', '__doc__', '__name__', '__package__', 'sys', 'x', 'y']
&gt;&gt;&gt; sys.getrefcount(x)
3
&gt;&gt;&gt; del x               # remove "x" as a known variable
&gt;&gt;&gt; dir()               # known variables includes only "y"
['__builtins__', '__doc__', '__name__', '__package__', 'sys', 'y']
&gt;&gt;&gt; sys.getrefcount(y)  # reference count is now lower by 1
2
&gt;&gt;&gt; del y               # remove "y" as a known variable
&gt;&gt;&gt; dir()               # known variables no longer include "x" and "y"
['__builtins__', '__doc__', '__name__', '__package__', 'sys']
&gt;&gt;&gt; x                   # unresolved variable raises a "NameError"

Traceback (most recent call last):
  File "&lt;pyshell#12&gt;", line 1, in &lt;module&gt;
    x                  # unresolved variable raises a "NameError"
NameError: name 'x' is not defined
</code></pre>

python