I am writing a large batch-type script in Python, and need to do some cleanup in the end, regardless of whether an exception occurred. To do this I’m simply putting the main program in a try block and the cleanup in a finally block.
This seems to work well, but my question is how to print any exceptions that might occur. Currently it just ignores them and jumps to the finally block.
you can use traceback.
something like: