traceback.print_exc()
traceback.print_exc() is a Python function in the Traceback Module category. Prints the formatted traceback of the current exception to stdout/stderr. The syntax is traceback.print_exc(limit=None, file=None, chain=True). Returns: None. A typical example: try:
1/0
except:
traceback.print_exc() # Prints to stderr. A close sibling is traceback.format_exc(), which returns the formatted traceback of the current exception as a string. A close sibling is traceback.extract_tb(), which extracts a traceback into a list of FrameSummary objects. 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.extract_tb(), 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.print_exc() immediately in the Python playground, look up unfamiliar terms in the glossary, or return to the Python Reference homepage.