Skip to content
Advertisement

Tag: stack-trace

Print current call stack from a method in code

In Python, how can I print the current call stack from within a method (for debugging purposes). Answer Here’s an example of getting the stack via the traceback module, and printing it: If you really only want to print the stack to stderr, you can use: Or to print to stdout (useful if want to keep redirected output together), use:

Advertisement