image
image
image

Deleting an Object

image

Example

Start IDLE.

Navigate to the File menu and click New Window.

Type the following:

complex1=NumberComplex(1,3)

del complex1

Discussion

When complex1=NumberComplex(1,3) is done, a new instance of the object  gets generated in memory and the name complex1 ties with it. The object does not immediately get destroyed as itt temporarily stays in memory before the garbage collector purges it from memory. The purging of the object helps free resources bound to the object and enhances system efficiency. Garbage destruction Python refers to automatic destruction of unreferenced objects.