How to determine if an exception was raised once you're in the finally block?
问题 Is it possible to tell if there was an exception once you're in the finally clause? Something like: try: funky code finally: if ???: print('the funky code raised') I'm looking to make something like this more DRY: try: funky code except HandleThis: # handle it raised = True except DontHandleThis: raised = True raise else: raised = False finally: logger.info('funky code raised %s', raised) I don't like that it requires to catch an exception, which you don't intend to handle, just to set a flag