On this page
traceback.print_last
Prev: traceback.print_exception | Up: traceback | Next: traceback.print_list
Rel: traceback.clear_frames, traceback.extract_stack, traceback.extract_tb, traceback.format_exc
Ref: docs.python.org — traceback.print_last
Tags: #public #python3 #stdlib #traceback
Import
import traceback
from traceback import print_last
Signature & Overview
traceback.print_last(limit=None, file=None, chain=True)
This is a shorthand for 'print_exception(sys.last_exc, limit=limit, file=file, chain=chain)'.
Usage
import traceback
# Interactive REPL helper printing sys.last_traceback (raises ValueError if none)
assert callable(traceback.print_last)
Gotchas
- REPL-only: Inside scripts, use
print_exc()inside anexcept:block.
REPL Inspect
from traceback import print_last
help(print_last)
Linked from
Related notes
- tuts/python3/stdlib_module/traceback/print_exception Linked here; links to this page; shared tags: #stdlib, #traceback
- tuts/python3/stdlib_module/traceback/print_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_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