On this page
  1. sys.exc_info
  2. Import
  3. Signature & Overview
  4. Usage
  5. Gotchas
  6. REPL Inspect

sys.exc_info

Prev: sys.displayhook | Up: sys | Next: sys.excepthook
Rel: sys.activate_stack_trampoline, sys.addaudithook, sys.audit, sys.breakpointhook
Ref: docs.python.org — sys.exc_info
Tags: #public #python3 #stdlib #sys


Import

import sys
from sys import exc_info

Signature & Overview

sys.exc_info()

Return current exception information: (type, value, traceback).

Usage

import sys

try:
    1 / 0
except ZeroDivisionError:
    exc_type, exc_val, exc_tb = sys.exc_info()
    assert exc_type is ZeroDivisionError and isinstance(exc_val, ZeroDivisionError)

Gotchas

REPL Inspect

from sys import exc_info
help(exc_info)

Linked from

Related notes