Module 00
Python Refresher for AI Engineering
Ten story-driven lessons that take you from variables and loops to calling three different LLM providers, validating their replies and crunching six months of orders with pandas. Every example uses Crumb & Co.'s real problems: orders, menus, support tickets and a WhatsApp bot. Every snippet runs, and the expected output is shown beside it.
By the end of this module you can
- read and write everyday Python: collections, loops, functions, comprehensions, classes and dataclasses
- handle messy JSON, missing values and errors without crashing, and leave a clear log of what happened
- set up a project with uv, a virtual environment and a .env file, without ever hard-coding an API key
- validate outside data, including LLM output, with type hints and Pydantic models
- call APIs and LLMs safely, with timeouts, status checks, retries, async concurrency and provider-neutral response handling
- load, clean and summarise data with NumPy and pandas, and explain what a tensor is
Lessons
10 in this module- 01Python basics: variables, collections, loops and functionsWrite small Python programs with variables, the core data types, lists, tuples, sets and dictionaries, conditionals, loops, functions and imports, and explain why each fact should live in one place.
- 02Pythonic data handling: comprehensions, JSON and NoneRead nested JSON-shaped data safely, then filter, transform, sort, count and summarise it with comprehensions, sorted(), Counter and correct handling of None and missing keys.
- 03Classes, objects and dataclassesModel real things like orders, tickets and conversations as classes and dataclasses, choose between inheritance and composition, and decide when a plain function is the better tool.
- 04Errors, logging and debuggingRead tracebacks from the bottom up, catch only the exceptions you can handle, raise clear custom exceptions, log what happened with the right levels, and debug methodically.
- 05Files, .env, virtual environments and project structureRead and write text and JSON files with paths that work from anywhere, keep API keys in environment variables and .env files, and set up a reproducible project with uv and a virtual environment.
- 06Type hints and PydanticWrite typed function signatures, use a type checker to catch mistakes before running, and validate outside data, especially LLM replies, with Pydantic models that coerce safely and reject the rest.
- 07Async Python: doing many things while you waitUse async/await and asyncio.gather to overlap slow network calls, cap concurrency with a semaphore, handle failures and timeouts in batches, and avoid the blocking calls that silently undo it all.
- 08Python for APIs: requests, httpx and secretsMake HTTP requests with requests and httpx, read methods, status codes and headers, send API keys safely, validate responses, and handle timeouts and retries the way production code does.
- 09Python for AI workflowsBuild a provider-neutral LLM workflow: prompt templates, adapters that normalise Claude, OpenAI and Gemini responses, robust JSON extraction and validation, cost tracking, a self-correcting retry and a small argparse CLI.
- 10NumPy, pandas and the idea of tensorsUse NumPy arrays and vectorized operations, load, clean and summarise a real-sized dataset with pandas, plot it with matplotlib, and reason about tensor shapes before meeting PyTorch.