All Courses

How to Delete Python Object?

By Neha, 2 years ago
  • Bookmark
0

How to delete object in python and free memory space?

Object
Python
1 Answer
0

Garbage collection is a very important aspect of any good programming language. Likewise, Python lets us delete a lot of stuff, including objects.


To delete an object in Python, we use the ‘del’ keyword. A when we try to refer to a deleted object, it raises NameError.


>>> del orange
>>> orange

------------------------------------------------------------------------------------------------------
Traceback (most recent call last):
File “<pyshell#729>”, line 1, in <module>
orange
NameError: name ‘orange’ is not defined
-------------------------------------------------------------------------------------------------------


Your Answer

Webinars

Why You Should Learn Data Science in 2023?

Jun 8th (7:00 PM) 289 Registered
More webinars

Related Discussions

Running random forest algorithm with one variable

View More