Beyond Bash
For decades, system administrators relied on Bash scripts to glue systems together. Bash is excellent for simple, sequential tasks on a single Linux server — piping commands together, moving files, triggering other programs. It is the native language of the shell, and for that narrow job, nothing beats it.
However, modern cloud infrastructure involves managing thousands of resources across different providers, parsing complex nested JSON API responses, implementing retry logic, and coordinating asynchronous operations. Trying to do this in Bash means wrestling with awk, sed, jq, and fragile string manipulation that breaks the moment an API response changes its whitespace. A missing quote or an unexpected newline can silently corrupt data or delete the wrong resources.
Python became the standard language for Operations and DevOps because it solves exactly these problems:
- It handles data natively: Python lists and dictionaries map directly to JSON arrays and objects. Parsing a complex API response is a single function call, not a pipeline of text tools.
- Rich ecosystem: Libraries like
boto3(AWS),google-cloud-python(GCP),azure-sdk-for-python(Azure),requests(HTTP), andparamiko(SSH) do the heavy lifting. You write the logic; the library handles the protocol. - Readability and maintainability: Python code is often described as "executable pseudocode." A script written by one engineer can be understood and modified by another six months later — critical in on-call situations.
- Error handling: Python's exception model (
try/except/finally) gives you precise control over failure modes. Bash's error handling (set -e,$?) is comparatively primitive.
The result is that Python is now the dominant language for cloud SDKs, configuration management tools (Ansible is written in Python), infrastructure testing frameworks (Testinfra), and ops automation scripts across the industry.
Interviewers often ask: "When would you use Python over Bash for a task?" The defensible answer is: use Bash when you are orchestrating other shell commands in a linear sequence on a single machine; use Python when you need to handle structured data (JSON/YAML), call HTTP APIs, implement retry/error logic, or when the script will be maintained by a team over time. The inflection point is roughly: if you find yourself using awk or jq to parse data, switch to Python.