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

sys.exit

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


Import

import sys
from sys import exit

Signature & Overview

sys.exit(status=None, /)

Exit the interpreter by raising SystemExit(status).

Usage

import sys

try:
    sys.exit(2)
except SystemExit as exc:
    assert exc.code == 2

Gotchas

REPL Inspect

from sys import exit
help(exit)

Linked from

Related notes