What's the use of the __del__() method in Python?
It can be used to dispose of resources managed by the object : https://github.com/python/cpython/blob/master/Lib/zipfile.py#L1805
As noted in the docstring, this is a kind of last resort as the object with be closed only when gc is running.
As you said in your question, the prefered way is to call close
yourself, either by calling .close()
directly or using a context manager with Zipfile() as z: