In short
Bash is perfect until your script needs to call three APIs, parse JSON and handle retries. That's when DevOps engineers reach for Python, and the script stays readable a year later.
Python is a popular choice for automating repetitive work because its standard library handles files, dates, JSON and processes, and packages like requests cover web APIs. Scripts stay readable even as they grow.

Think of it like this
Auto-rickshaw vs a car
For a quick trip down the gully, an auto is perfect: hop in, two minutes, done. For a long drive with family and luggage, you want a car with space and a proper boot. Bash is the auto for short jobs. Python is the car for bigger, longer ones.
Watch it happen
A health-check script at work
GET /health
1/5The script calls each service's health endpoint with a 5-second timeout.
The big ideas
What you need to know
Batteries included
Python's standard library handles files, JSON, subprocesses and dates. requests and boto3 cover HTTP and AWS.
Use a virtual environment
python3 -m venv .venv keeps each tool's libraries separate, so one upgrade doesn't break another script.
argparse for real CLIs
Give scripts proper flags like --env and --dry-run with help text, instead of guessing what $1 means.
Bash or Python?
Mostly gluing commands together? Bash. Logic, loops over data, APIs or error handling? Python.
See it in code
Walk through the code
1import os, sys2import requests3 4URLS = ["https://shop.example.com/health", "https://api.example.com/health"]5WEBHOOK = os.environ["SLACK_WEBHOOK_URL"]6failed = []7for url in URLS:8 try:9 r = requests.get(url, timeout=5)10 r.raise_for_status()11 except requests.RequestException as e:12 failed.append(f"{url}: {e}")13 14if failed:15 requests.post(WEBHOOK, json={"text": "\n".join(failed)}, timeout=5)16 sys.exit(1)1/4Standard library modules plus requests, the go-to library for HTTP calls.
Install requests inside a venv with pip install requests. Reading the webhook from an environment variable keeps the secret out of the code.
Save yourself the pain
Common mistakes
Oops
Calling requests.get without a timeout, so the script hangs forever when a server stops responding.
Do this instead
Always pass timeout=. A stuck automation script is often worse than one that fails quickly.
Oops
Installing packages with sudo pip into the system Python.
Do this instead
Use a venv per project. Many distros now block system-wide pip installs for this reason.
Your mission
Your first ops script
Quick check
Why should an automation script exit with a non-zero code when a check fails?
Go deeper
- 1List three boring tasks you repeat every week and pick one to automate.
- 2Write the steps as comments first, then turn each into code.
- 3Add logging and clear error messages so you know when a script fails.
Also part of these roadmaps
More topics at this stop
Stuck on this topic? Ask an Insider
Get 1:1 guidance from people who've walked this exact path — on the InsideEdge app.