subprocess

Running other programs and shell commands from Python.

Also called: os.system, shell command

Source
General
Languages
Python, Bash

In plain English

Pass the command as a list, not one string, so file names with spaces and odd characters are safe.

Example

subprocess.run calls git status from inside the Python script.

In code

import subprocess
out = subprocess.run(["git", "status", "--short"], capture_output=True, text=True, check=True)
print(out.stdout)

Learn more

Related terms

Added 2026-11-30 · Last reviewed 2026-11-30