Python Craft
Mission. Turn “works in my notebook” Python into professional, tested, reviewable code.
Scope
- Idiomatic Python and the data model
- Type hints, mypy, and static checking
- Testing with pytest, including testing data code
- Debugging, profiling, and performance work
- Async Python
- Packaging, environments, and project structure
- Notebook discipline and reproducibility
- Code review and git workflows
Learning objectives
- Write typed, tested modules another engineer can review without a meeting
- Profile before optimizing, and say why code is slow with evidence
- Structure a project (src layout, pyproject, CI-ready tests) from scratch
- Keep exploratory notebooks from rotting into unrunnable artifacts
Lessons
This track is scaffolded and waiting for content. See the curriculum dashboard for the roadmap and progress across all tracks.
In review — 1 draft awaiting publication
Planned lessons (23)
Wave 1 — first vertical slice (production-ready) — 23 lessons
foundations
- Comprehensions and Generators Build collections and lazy pipelines the way fluent Python does.
- Functions, Closures, Decorators First-class functions, captured state, and wrapping behavior without magic.
- Error Handling That Doesn't Lie Exceptions that carry information, and the difference between failing loud and failing wrong.
- Dataclasses Structured records without the boilerplate, and when a dict is still fine.
typing
- Type Hints in Practice Annotate real code: signatures, generics, and what types do and don't check.
- Static Checking with mypy Run mypy on a real project, read the errors, and keep the config honest.
testing
- pytest Fundamentals Write tests that fail for the right reason and run in any order.
- Fixtures and Parametrize Reuse setup and cover the matrix of cases without copy-paste.
- Testing Data Code Test transforms, schemas, and edge cases without turning tests into brittle snapshots.
- Property-Based Testing Generate adversarial inputs with Hypothesis and let invariants find the bugs.
performance
- Debugging with pdb Stop print-debugging: breakpoints, stepping, and inspecting live state.
- Profile Before Optimizing Measure first: cProfile, line_profiler, and locating the actual bottleneck.
- Vectorize or Rewrite A slow data script made fast, and the analysis that chose the fix.
- Python's Memory Model for Data What Python actually holds in memory, and why big data lives in NumPy.
- Async Python Where await pays off for data work, and where threads beat it.
engineering
- Environments and Pinning Virtual environments, lockfiles, and installs that reproduce.
- Project Structure and pyproject.toml src layout, pyproject.toml, and a project another engineer can run.
- Building a CLI Wrap an analysis in a real command-line tool with argparse or typer.
- Notebook Discipline Keep notebooks runnable: kernels, seeds, exports, and the boundary to modules.
- Refactoring Data Scripts Turn a 400-line analysis script into a testable module without losing behavior.
- Logging for Data Work Progress, provenance, and errors you can find after the run.
communication
- Code Review for Data Code A checklist for reviewing analysis code: correctness, reproducibility, honesty.
- Git for Small Teams Branches, PRs, and a review flow that survives data projects.