traceback.format_tb()
traceback.format_tb() is a Python function in the Traceback Module category. Formats a traceback as a list of strings. The syntax is traceback.format_tb(tb, limit=None). Returns: List of strings. A typical example: lines = traceback.format_tb(tb)
print("".join(lines)). 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.extract_tb(), which extracts a traceback into a list of FrameSummary objects. 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.extract_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.format_tb() immediately in the Python playground, look up unfamiliar terms in the glossary, or return to the Python Reference homepage.