When an exception occurs in Python, can you inspect the stack? Can you determine its depth? I\'ve looked at the traceback module, but I can\'t figure out how to use it.
traceback is enough - and I suppose that documentation describes it rather well. Simplified example:
traceback
import sys import traceback try: eval('a') except NameError: traceback.print_exc(file=sys.stdout)