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

sys.exception

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


Import

import sys
from sys import exception

Signature & Overview

sys.exception()

Return the current exception.

Usage

import sys

assert sys.exception() is None
try:
    raise ValueError("bad")
except ValueError:
    assert isinstance(sys.exception(), ValueError)

Gotchas

REPL Inspect

from sys import exception
help(exception)

Linked from

Related notes