Module 15: Real-world Python

Packages and virtual environments, talking to web APIs, and databases with sqlite3.

  1. Projects and packages: A package is a folder with init.py; imports search sys.path in order; venv + requirements.txt pin libraries; argparse reads options; type hints are labels Python does not enforce.
  2. Web APIs and JSON: requests.get/post(url, params=/json=, timeout=) returns a response: check statuscode or raiseforstatus(), then .json(); always set a timeout.
  3. Databases from Python: sqlite3: connect, cursor, execute(sql, (values,)) with ?, commit(), fetch; never build SQL with f-strings; with conn: is all-or-nothing.

Ends with a 12-question checkpoint (80% passes) and a mini project: Canteen Counter Pro: the data layer.