__del__
Dunder MethodPython 2.0+Advanced
Destructor; called when the object is about to be garbage collected
Quick Info
- Documentation
- Official Docs
- Python Version
- 2.0+
Learn by Difficulty
Quick Example
python
class Example: def __del__(self): return "Example __del__" obj = Example() print(obj)
__del__ destructor; called when the object is about to be garbage collected. Implementing it lets you customize how Python interacts with your objects.
Try in PlaygroundTags
oopmagic-methodprotocolcore