traceback.TracebackException.format_exception_only()

format_exception_only() Format the exception part of the traceback. The return value is a generator of strings, each ending in a newline. Normally, the generator emits a single string; however, for SyntaxError exceptions, it emits several lines that (when printed) display detailed information about where the syntax error occurred. The message indicating which exception occurred is always the last string in the output.

traceback.TracebackException.format()

format(*, chain=True) Format the exception. If chain is not True, __cause__ and __context__ will not be formatted. The return value is a generator of strings, each ending in a newline and some containing internal newlines. print_exception() is a wrapper around this method which just prints the lines to a file. The message indicating which exception occurred is always the last string in the output.

traceback.TracebackException.lineno

lineno For syntax errors - the line number where the error occurred.

traceback.TracebackException.filename

filename For syntax errors - the file name where the error occurred.

traceback.TracebackException.exc_type

exc_type The class of the original traceback.

traceback.print_exc()

traceback.print_exc(limit=None, file=None, chain=True) This is a shorthand for print_exception(*sys.exc_info(), limit, file, chain).

traceback.print_stack()

traceback.print_stack(f=None, limit=None, file=None) Print up to limit stack trace entries (starting from the invocation point) if limit is positive. Otherwise, print the last abs(limit) entries. If limit is omitted or None, all entries are printed. The optional f argument can be used to specify an alternate stack frame to start. The optional file argument has the same meaning as for print_tb(). Changed in version 3.5: Added negative limit support.

traceback.print_exception()

traceback.print_exception(etype, value, tb, limit=None, file=None, chain=True) Print exception information and stack trace entries from traceback object tb to file. This differs from print_tb() in the following ways: if tb is not None, it prints a header Traceback (most recent call last): it prints the exception etype and value after the stack trace if etype is SyntaxError and value has the appropriate format, it prints the line where the syntax error occurred with a caret indicating the ap

traceback.StackSummary.from_list()

classmethod from_list(a_list) Construct a StackSummary object from a supplied old-style list of tuples. Each tuple should be a 4-tuple with filename, lineno, name, line as the elements.

traceback.StackSummary.extract()

classmethod extract(frame_gen, *, limit=None, lookup_lines=True, capture_locals=False) Construct a StackSummary object from a frame generator (such as is returned by walk_stack() or walk_tb()). If limit is supplied, only this many frames are taken from frame_gen. If lookup_lines is False, the returned FrameSummary objects will not have read their lines in yet, making the cost of creating the StackSummary cheaper (which may be valuable if it may not actually get formatted). If capture_locals