We all have heard things like python is a memory safe language, and memory manageement is done automatically in python.
Its the Garbage collector which is responsible for freeing memory when an object is no longer required by the program.
Consider this program below:
del is a magic method which is called when an object is destroyed.
create some refrences to the class A.
the above can be represented by something like this:
Now assume at some point in program we modify the above objects like this:
now since there is no refrence to class A , the object A() is destroyed and hence the output above.
above situation can be represented as :