Useful Batteries Included
Scenario: An automation script needs arguments, environment variables, randomness, counters, and filesystem details.
New words, in plain English
- Standard library - modules shipped with Python
- os - operating-system paths, environment, and process helpers
- sys - interpreter information and command-line/runtime hooks
- collections - specialized containers such as Counter and defaultdict
Reach for pathlib, os, sys, argparse, subprocess, shutil, tempfile, logging, random, secrets, statistics, collections, and itertools before adding a package. Use secrets, not random, for credentials.
Analogy: A Python program is like a clear set of instructions for a careful helper: names label things, indentation groups steps, and errors explain where the helper became confused.
A small, real example
import os, sys
from collections import Counter
print(os.environ.get("ENVIRONMENT", "dev"))
print(sys.version_info.major)
print(Counter(["ok", "fail", "ok"]))
Tip: Read a module's official documentation and inspect it with help(module).
Goal: Practice this idea in the py-regex-datetime challenge at/labs/python. Fix the broken program, run it yourself, then usecheckto prove the real end state.