traceback.format_exc()
can get it with raising an exception.
traceback.print_stack()
prints the stack without an exception needed, but it does not return a string.
There doesn't seem to be a way to get the stack trace string without raising an exception in python?
It's traceback.extract_stack()
if you want convenient access to module and function names and line numbers, or ''.join(traceback.format_stack())
if you just want a string that looks like the traceback.print_stack()
output.
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments