PyDocs

Nav

Python Runtime Services

TracebackException.format_exception_only

  • TracebackException.format_exception_only(*, show_group=False)
Format the exception part of the traceback.

The return value is a generator of strings, each ending in a newline.

Generator yields the exception message.
For :exc:`SyntaxError` exceptions, it
also yields (before the exception message)
several lines that (when printed)
display detailed information about where the syntax error occurred.
Following the message, generator also yields
all the exception's ``__notes__``.

When *show_group* is ``True``, and the exception is an instance of
:exc:`BaseExceptionGroup`, the nested exceptions are included as
well, recursively, with indentation relative to their nesting depth.
Changed in 3.11, 3.13
  • 3.11: The exception’s notes are now included in the output.
  • 3.13: Added the show_group parameter.
0 Examples
No examples for traceback/TracebackException.format_exception_only.
See Also
No see-alsos for traceback/TracebackException.format_exception_only
0 Notes
No notes for TracebackException.format_exception_only