Python Glossary Русский

all Python 3tracebackfunction

traceback.print_list()

printing tracebacks

Prints a list of frames (from extract_tb or extract_stack) in traceback format; to stderr by default.

Syntax

traceback.print_list(extracted_list, file=None)

It is ''.join(format_list(...)) written to a stream, in one call. Handy for printing a filtered or trimmed stack. It prints no "Traceback…" header and no exception line — only the frames. Plain tuples (filename, lineno, name, line) are accepted, so frames can be assembled by hand.

Examples

import sys, traceback
traceback.print_list([('app.py', 10, 'main', 'run()')], file=sys.stdout)
print('---')  # → ---
import sys, traceback
rows = [('app.py', 10, 'main', 'run()')]
print(''.join(traceback.format_list(rows)), end='')
# → File "app.py", line 10, in main / run()

See also

Open in the full glossarydocs.python.orgReport an inaccuracy