Skip to content

Commit b2776be

Browse files
committed
📝 Add del statement
1 parent 7c34ea8 commit b2776be

1 file changed

Lines changed: 15 additions & 0 deletions

File tree

docs/variables-expressions.rst

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,21 @@ for the first time.
4646
``y = 4``, causes ``y`` to refer to the integer object ``4``, but this does
4747
not change the references of ``x`` or ``z``.
4848

49+
When deleting variables using the :ref:`del <del>` statement, only the
50+
reference is deleted, not the object itself:
51+
52+
.. code-block:: pycon
53+
54+
>>> del y
55+
>>> print(y)
56+
Traceback (most recent call last):
57+
File "<python-input-10>", line 1, in <module>
58+
print(y)
59+
^
60+
NameError: name 'y' is not defined
61+
>>> print(x, z)
62+
1 1
63+
4964
Python variables can be set to any object, whereas in many other languages
5065
variables can only be stored in the declared type.
5166

0 commit comments

Comments
 (0)