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 approximate position of the error.

The optional limit argument has the same meaning as for print_tb(). If chain is true (the default), then chained exceptions (the __cause__ or __context__ attributes of the exception) will be printed as well, like the interpreter itself does when printing an unhandled exception.

doc_python
2016-10-07 17:45:11
Comments
Leave a Comment

Please login to continue.