To delete a file in Python, I’m using os.remove.
The docs (linked) don’t give any indication of any exceptions except for OSError:
If path is a directory, OSError is raised
How do I check for exceptions such as FileNotFound, PermissionToDeleteDenied, etc? Or is such error checking not done by the os.remove function (the docs for os.remove and os.unlink don’t seem to say)?
OSErrorexceptions have anerrnoattribute which you can use together with theerrnomodule to get more information about what type of OS error occurred. See the documentation for OSError.