A stack trace is something you get printed out in case your code runs into an (uncaught) exception. It usually shows you nicely which function(s) invoked the function finally causing the exception.
Today I had a problem with one of my functions in one of my programs ( a testing framework ): it didn't throw an exception, but it produced incorrect results. Since this function can be called from many places within my program I wanted to print out a stack trace intentionally every time that function is invoked.
Python module traceback helped me out here nicely and these two lines of code did what I needed to finally figure out from where my function was called when it failed to produce correct results:
0 blog comments below