traceback.extract_tb()
traceback.extract_tb() is a Python function in the Traceback Module category. Extracts a traceback into a list of FrameSummary objects. The syntax is traceback.extract_tb(tb, limit=None). Returns: List of FrameSummary objects. A typical example: tb = traceback.extract_tb(sys.exc_info()[2])
for frame in tb:
print(frame.filename, frame.lineno). A close sibling is traceback.format_exc(), which returns the formatted traceback of the current exception as a string. A close sibling is traceback.print_exc(), which prints the formatted traceback of the current exception to stdout/stderr. A close sibling is traceback.format_tb(), which formats a traceback as a list of strings. A close sibling is traceback.print_last(), which prints the last formatted exception. More about this category: Exception traceback handling — format_exc, print_exc, extract_tb. Related Traceback Module entries: traceback.format_exc(), traceback.print_exc(), traceback.format_tb(), traceback.print_last(). This page is part of the free Python Reference documentation covering 978+ functions, methods, and modules with examples and parameter details. You can try traceback.extract_tb() immediately in the Python playground, look up unfamiliar terms in the glossary, or return to the Python Reference homepage.