traceback.format_exception_only
Prev: traceback.format_exception | Up: traceback | Next: traceback.format_list
Rel: traceback.clear_frames, traceback.extract_stack, traceback.extract_tb, traceback.format_exc
Ref: docs.python.org — traceback.format_exception_only
Tags: #public #python3 #stdlib #traceback
Import
import traceback
from traceback import format_exception_only
Signature & Overview
traceback.format_exception_only(exc, /, value=<implicit>, *, show_group=False, **kwargs)
Format the exception part of a traceback.
Usage
import traceback
lines = traceback.format_exception_only(ValueError, ValueError('bad'))
assert lines == ['ValueError: bad\n']
Gotchas
- Formats only the final exception line(s), omitting the stack trace.
REPL Inspect
from traceback import format_exception_only
help(format_exception_only)
Linked from
Related notes
- tuts/python3/stdlib_module/traceback/format_exception Linked here; links to this page; shared tags: #stdlib, #traceback
- tuts/python3/stdlib_module/traceback/format_list Linked here; links to this page; shared tags: #stdlib, #traceback
- tuts/python3/stdlib_module/traceback Linked here; links to this page; shared tags: #stdlib
- tuts/python3/stdlib_module/traceback/clear_frames Linked here; shared tags: #stdlib, #traceback
- tuts/python3/stdlib_module/traceback/extract_stack Linked here; shared tags: #stdlib, #traceback
- tuts/python3/stdlib_module/traceback/extract_tb Linked here; shared tags: #stdlib, #traceback
- tuts/python3/stdlib_module/traceback/format_exc Linked here; shared tags: #stdlib, #traceback
- tuts/python3/stdlib_module/traceback/format_stack shared tags: #stdlib, #traceback
- tuts/python3/stdlib_module/traceback/format_tb shared tags: #stdlib, #traceback
- tuts/python3/stdlib_module/traceback/FrameSummary shared tags: #stdlib, #traceback