On this page
traceback.walk_tb
Prev: traceback.walk_stack | Up: traceback
Rel: traceback.clear_frames, traceback.extract_stack, traceback.extract_tb, traceback.format_exc
Ref: docs.python.org — traceback.walk_tb
Tags: #public #python3 #stdlib #traceback
Import
import traceback
from traceback import walk_tb
Signature & Overview
traceback.walk_tb(tb)
Walk a traceback yielding the frame and line number for each frame.
Usage
import traceback
try:
1 / 0
except ZeroDivisionError as exc:
pairs = list(traceback.walk_tb(exc.__traceback__))
assert len(pairs) >= 1
Gotchas
- Yields
(frame, lineno)pairs walking down a traceback.
REPL Inspect
from traceback import walk_tb
help(walk_tb)
Linked from
Related notes
- tuts/python3/stdlib_module/traceback/walk_stack 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
- tuts/python3/stdlib_module/traceback/format_stack shared tags: #stdlib, #traceback