Python sys: system-specific parameters and functions
Answer: The sys module provides access to variables used or maintained by the interpreter, and to functions that interact strongly with it.
What you can read
It is always available.
Unless explicitly noted otherwise, all variables are read-only.
argv is the list of command line arguments passed to a Python script.
If no script name was passed to the interpreter, the first argv entry is the empty string.
Auditing hooks
Hooks can be added, but they are not suitable for implementing a sandbox.
Malicious code can trivially disable or bypass hooks added using this function.
See also
Claims
- id: C1 claim: Most variables in the module are read-only. source: S1 evidence: "Unless explicitly noted otherwise, all variables are read-only."
- id: C2 claim: argv lists command line arguments passed to a script. source: S1 evidence: "The list of command line arguments passed to a Python script."
- id: C3 claim: Most variables in the module are read-only. source: S2 evidence: "Unless explicitly noted otherwise, all variables are read-only."
- id: C4 claim: The module is always available. source: S2 evidence: "It is always available."
Sources
- [S1] sys — System-specific parameters and functions. Python Software Foundation. https://docs.python.org/3/library/sys.html . License: PSF License Version 2. Accessed 2026-11-25.
- [S2] sys documentation (source). CPython. https://raw.githubusercontent.com/python/cpython/main/Doc/library/sys.rst . License: PSF License Version 2. Accessed 2026-11-25.
License: this note is CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/). Summary by iinventedlight (AI-assisted). Sources: Python Software Foundation, sys — System-specific parameters and functions; CPython, sys documentation (source). PSF-2.0 (https://docs.python.org/3/license.html). Copyright Python Software Foundation. Text was condensed and changed from the originals.
License: CC-BY-4.0 · Summary by iinventedlight (AI-assisted). Sources: Python Software Foundation, sys — System-specific parameters and functions; CPython, sys documentation (source). PSF-2.0 (https://docs.python.org/3/license.html). Copyright Python Software Foundation.
Cite this
iinventedlight. 2026. "Python sys: system-specific parameters and functions." iinventedlight Library, iil:note:g7q2gjvz, version of 2026-11-25. https://iinventedlight.com/library/notes/python-sys/. License: CC-BY-4.0.
@misc{iil_note_g7q2gjvz,
author = {{iinventedlight}},
title = {{Python sys: system-specific parameters and functions}},
howpublished = {iinventedlight Library},
year = {2026},
date = {2026-11-25},
url = {https://iinventedlight.com/library/notes/python-sys/},
note = {Permanent ID iil:note:g7q2gjvz. License: CC-BY-4.0.},
}
Spotted a mistake? Use the MCP feedback tool or email hello@iinventedlight.com. Or Report a correction (no account needed).
Extra files beside this note
These files use this note's license, shown below. Paper extras retain their reproduction status; a link is not a reproduction.
- python-sys.schema.json (schema; CC-BY-4.0)
- python-sys.table.json (table; CC-BY-4.0)
For language models and agents: start at /llms.txt | /agents.md | /.well-known/agent-library.json. This page in Markdown: /library/notes/python-sys.md.