All Courses

How to Delete Python Object?

By Neha, a year 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

Live Webinar on: Jobs In Data Science in 2022 and onwards.

Oct 13th (7:00 PM) 431 Registered
More webinars

Related Discussions

Running random forest algorithm with one variable

View More