CKTIS / Python
sys — access to the Python interpreter
The sys module exposes interpreter parameters, program arguments, standard streams, and a function that signals program termination.
Version: Python 3.14; repository image, production runtime not attested
Syntax
import sys
sys.attribute
sys.function(...)sys provides interpreter-related variables and functions. Use import sys, then access its members through sys.name.
sys.argv contains command-line arguments; when running a script, sys.argv[0] is its name and sys.argv[1:] contains user arguments. sys.stdin, sys.stdout, and sys.stderr represent standard input, output, and error output.
sys.exit(0) raises SystemExit; zero indicates success. It does not force immediate termination: the exception can be caught, and finally blocks run. The example deliberately catches this exception.
Examples
import sys
sys.stdout.write("Hello\n")
try:
sys.exit(0)
except SystemExit as exc:
print(f"Exit code: {exc.code}")Result
Hello Exit code: 0
The displayed code and declared result were verified in an isolated environment using the method recorded in the verification evidence for this exact version.