<div class="section" id="the-del-statement">
<span id="del"></span><h2>The <a class="reference internal" href="#del"><tt class="xref std std-keyword docutils literal"><span class="pre">del</span></tt></a> statement</h2>
<pre id="index-18">
<strong id="grammar-token-del_stmt">del_stmt</strong> ::=  &quot;del&quot; <a class="reference internal" href="#grammar-token-target_list"><tt class="xref docutils literal"><span class="pre">target_list</span></tt></a>
</pre>
<p>Deletion is recursively defined very similar to the way assignment is defined.
Rather than spelling it out in full details, here are some hints.</p>
<p>Deletion of a target list recursively deletes each target, from left to right.</p>
<p id="index-19">Deletion of a name removes the binding of that name from the local or global
namespace, depending on whether the name occurs in a <a class="reference internal" href="#global"><tt class="xref std std-keyword docutils literal"><span class="pre">global</span></tt></a> statement
in the same code block.  If the name is unbound, a <a class="reference internal" href="../library/exceptions.html#NameError" title="NameError"><tt class="xref py py-exc docutils literal"><span class="pre">NameError</span></tt></a> exception
will be raised.</p>
<p id="index-20">Deletion of attribute references, subscriptions and slicings is passed to the
primary object involved; deletion of a slicing is in general equivalent to
assignment of an empty slice of the right type (but even this is determined by
the sliced object).</p>
<div class="versionchanged">
<p><span class="versionmodified">Changed in version 3.2: </span>Previously it was illegal to delete a name from the local namespace if it
occurs as a free variable in a nested block.</p>
</div>
</div>
