On this page
traceback.format_tb
Prev: traceback.format_stack | Up: traceback | Next: traceback.FrameSummary
Rel: traceback.clear_frames, traceback.extract_stack, traceback.extract_tb, traceback.format_exc
Ref: docs.python.org — traceback.format_tb
Tags: #public #python3 #stdlib #traceback
Import
import traceback
from traceback import format_tb
Signature & Overview
traceback.format_tb(tb, limit=None)
A shorthand for 'format_list(extract_tb(tb, limit))'.
Usage
import traceback
try:
1 / 0
except ZeroDivisionError as exc:
lines = traceback.format_tb(exc.__traceback__)
assert len(lines) >= 1
Gotchas
- Formats stack frames only (no exception header/footer).
REPL Inspect
from traceback import format_tb
help(format_tb)
Linked from
Related notes
- tuts/python3/stdlib_module/traceback/format_stack Linked here; links to this page; shared tags: #stdlib, #traceback
- tuts/python3/stdlib_module/traceback/FrameSummary 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_exception shared tags: #stdlib, #traceback
- tuts/python3/stdlib_module/traceback/format_exception_only shared tags: #stdlib, #traceback
- tuts/python3/stdlib_module/traceback/format_list shared tags: #stdlib, #traceback