๐ง Systems Concepts (read-only)
subprocess โ shell out safely
Run external commands and capture output.
subprocess.run is the modern, safe entry point. Pass a **list** of args (no shell=True) to avoid shell injection.
import subprocess
r = subprocess.run(
["echo", "hello"],
capture_output=True, text=True, check=True,
)
print(r.stdout.strip()) # hello
**Patterns**
check=Trueraises on non-zero exit โ fail fast.capture_output=True, text=Truefor stringstdout/stderr.- Long output โ
subprocess.Popenwith streaming reads.
> ๐งช Concept-only here โ the browser sandbox can't spawn processes.