Python sys Module The sys module provides access to variables and functions that interact with the Python interpreter itself. It exposes system-specific parameters, the module search path, and standard I/O streams. Use Cases: - Accessing command-line arguments - Modifying the module search path at runtime - Checking Python version information - Controlling the recursion limit - Redirecting standard input, output, and error streams Example 1: Command-line argument handling import sys if len(sys.argv) < 2: print(f"Usage: {sys.argv[0]} ", file=sys.stderr) sys.exit(1) filename = sys.argv[1] print(f"Processing: {filename}") print(f"Python version: {sys.version}") print(f"Platform: {sys.platform}") Example 2: Checking object sizes and recursion import sys data = {"key": "value", "numbers": list(range(100))} print(f"Dict size: {sys.getsizeof(data)} bytes") print(f"List size: {sys.getsizeof(data['numbers'])} bytes") print(f"Recursion limit: {sys.getrecursionlimit()}") # Increase recursion limit for deep algorithms sys.setrecursionlimit(5000) Key attributes include sys.argv (command-line arguments), sys.path (module search path), sys.stdin/stdout/stderr (I/O streams), sys.version (Python version string), sys.platform (OS identifier), and sys.modules (cached imported modules). For serious CLI applications, the argparse module is preferred over raw sys.argv.