I have a python class ReportGenerator which needs temporary directory to store intermediate files. Once object of ReportGenerator is destroyed my code is required to delete temporary folder.
Where to place directory removal code to make sure that once object is not referenced, the temp folder will be deleted.
In C++ it is obvious to delete folder in destructor of class. In python there is a __del__ but as I understand from other posts it is not recommended to use it in such situation. So in general what is a right way in python so one object can own a resource and release once it destroyed?