Destructors are called when an object gets destroyed. It’s the polar opposite of the constructor, which gets called on creation.
These methods are only called on creation and destruction of the object. They are not called manually but completely automatic.
Python Beyond the Basics – Object-Oriented Programming
The class below has a constructor (__init__) and destructor (__del__).
We create an instance from the class and delete it right after.
print('Destructor called, vehicle deleted.')
car = Vehicle()
Run the program to see this output:
Destructor called, vehicle deleted.
The output is displayed, even though we didn’t call any methods.