Hello,

Sometimes I work with third-party libraries and I want to check what is the path of calling methods and functions. So, the latest issue was related to a logging handler that is closed unexpectedly (for me). The simplest way to investigate was to add d = 1/0 into the "close" method of this handler. It causes an exception and I can see where it is called - so I can prevent the firing of this.

But maybe the "right" way is to use the traceback module:

import traceback

traceback.print_stack()
Print stack traces in Python landmark

PantheraLeo1359531, CC BY-SA 4.0, via Wikimedia Commons