On this page
traceback.StackSummary
Prev: traceback.print_tb | Up: traceback | Next: traceback.TracebackException
Rel: traceback.clear_frames, traceback.extract_stack, traceback.extract_tb, traceback.format_exc
Ref: docs.python.org — traceback.StackSummary
Tags: #public #python3 #stdlib #traceback
Import
import traceback
from traceback import StackSummary
Signature & Overview
traceback.StackSummary(iterable=(), /)
A list of FrameSummary objects, representing a stack of frames.
Methods & Attributes
StackSummary.append(self, object, /)— Append object to the end of the list.StackSummary.clear(self, /)— Remove all items from list.StackSummary.copy(self, /)— Return a shallow copy of the list.StackSummary.count(self, value, /)— Return number of occurrences of value.StackSummary.extend(self, iterable, /)— Extend list by appending elements from the iterable.StackSummary.extract(frame_gen, *, limit=None, lookup_lines=True, capture_locals=False)— Create a StackSummary from a traceback or stack object.StackSummary.format(self, **kwargs)— Format the stack ready for printing.StackSummary.format_frame_summary(self, frame_summary, **kwargs)— Format the lines for a single FrameSummary.StackSummary.from_list(a_list)— Create a StackSummary object from a supplied list of FrameSummary objects or old-style list of tuples.StackSummary.index(self, value, start=0, stop=9223372036854775807, /)— Return first index of value.StackSummary.insert(self, index, object, /)— Insert object before index.StackSummary.pop(self, index=-1, /)— Remove and return item at index (default last).StackSummary.remove(self, value, /)— Remove first occurrence of value.StackSummary.reverse(self, /)— Reverse IN PLACE.StackSummary.sort(self, /, *, key=None, reverse=False)— Sort the list in ascending order and return None.
Usage
import traceback
ss = traceback.extract_stack(limit=3)
assert isinstance(ss, traceback.StackSummary) and len(ss) <= 3
Gotchas
- Call
ss.format()to render formatted lines for logs.
REPL Inspect
from traceback import StackSummary
help(StackSummary)
Linked from
Related notes
- tuts/python3/stdlib_module/traceback/print_tb Linked here; links to this page; shared tags: #stdlib, #traceback
- tuts/python3/stdlib_module/traceback/TracebackException 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