traceback

The traceback module is used to gather and print stack traces of a program after an exception has occurred. The functions in this module operate on traceback objects such as the third item returned by the sys.exc_info() function.

print_tb(traceback [, limit [, file]])

Prints up to limit stack trace entries from traceback to the file file. If limit is omitted, all the entries are printed. If file is omitted, the output is sent to sys.stderr.

print_exception(type, value, traceback [, limit [, file]])

Prints exception information and a stack trace to file.type is the exception type, and value is the exception value. limit and file are the same as in print_tb().

print_exc([limit [, file]])

Same as print_exception() applied to the information ...

Get Python: Essential Reference, Third Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.