Deleting an entire object

Deleting an entire object

Lesson Details:
June 29, 2020


I: Introduction

A: Python is a high level, object-oriented programming language. It is the second most popular language that is used for writing applications.

II: Body

A: In python you can delete an entire object.

III: Conclusion

I: Introduction

A: Python is a high level, object-oriented programming language. It is the second most popular language that is used for writing applications.

II: Body

A: In python you can delete an entire object. When you delete an entire object it deletes everything from that object including all values and objects contained in that object. If you have a list of objects then deleting the list will delete all objects that were contained in that list. You will need to use a function called del to delete an entire object. The syntax for this function is as follows: del(object). You can also use this function on an object that has been assigned to a variable. For example if my_list = [1,2,3] then del(my_list) will delete all three numbers because my_list was an entire object. Deleting an entire object will not delete any variables or values that are contained in that object. You can also enter the following commands to see what happens when you delete an entire object:

>>> my_list = [1,2,3] >>> del(my_list) >>> my_list Traceback (most recent call last): File "", line 1, in my_list NameError: name 'my_list' is not defined >>>

III: Conclusion

loader
Course content