ID EN
Traceback

format_exception_only

Python 3.11

Format the exception part of a traceback using an exception value such as given by sys.last_value. The return value is a list of strings, each ending in a newline. The list contains the exception’s message, which is normally a single string; however, for SyntaxError exceptions, it contains several lines that (when printed) display detailed information about where the syntax error occurred. Following the message, the list contains the exception’s notes.

Syntax

PYTHON
traceback.format_exception_only(exc, /[, value])

See Also

sys.last_value SyntaxError notes notes