traceback

traceback is a Python object which provides standard interface to extract, format and print the stack traces similar to the Python interpreter. 1

It exposes functions such as print_tb (print stack trace entries), print_stack (almost the same to print_tb), extract_tb (return StackSummary object that contain a list of FrameSummary object), extract_stack (same as extract_tb), format_tb (return a list of strings processed based on the extract_tb output) and format_stack (same as format_tb but dealing with extract_stack instead).

FrameSummary object is representing a ready to print information for stack trace. It includes data such as file name, line number, name, line and variable representation.

Links to this page
  • Python Context Management Protocol

    The method accepts three parameters (discounting self, which points to the object itself): type, value and traceback. type is of type of the exception’s class, value represents the instance of the exception and traceback describes 202206101517#. You can utilise these parameters to your exception handling within the class method.