When is del useful in Python?

I can’t really think of any reason why Python needs the del keyword (and most languages seem to not have a similar keyword). For instance, rather than deleting a variable, one could just assign None to it. And when deleting from a dictionary, a del method could be added.

Is there a reason to keep del in Python, or is it a vestige of Python’s pre-garbage collection days?

24 Answers
24

Leave a Comment