No description
  • Python 93%
  • HTML 5.7%
  • Java 1.3%
Find a file
Feiko 558743afc1
All checks were successful
Build and Release PDFs and HTML / build (push) Successful in 1m56s
Simplify the capstone, and stop the slides giving it away
Two problems with the first version. It was too much work for the slot,
and the domain was doing the teaching: students would have spent the
afternoon learning about tractive effort, gradient resistance in per-mille
and Roeckl's formula for curve resistance instead of about refactoring.

The railway stays, the railway engineering goes. A wagon now weighs what
it weighs plus what it carries, and an engine can pull that or it cannot.
The starter drops from 430 lines to 164, the solution from eleven modules
to five, and the guide from eight steps to four. Dispatch tables and
dependency injection move to If time permits, which frees about an hour.

The reveal survives intact and is sharper for being arithmetic: service S1
reports 16 minutes when the answer is 32, because the second copy of the
weight calculation counts the wagons and forgets the cargo. A light train
is unaffected, so the bug only bites the services that matter.

The slides no longer use the railway at all. They were enumerating exactly
what step 1 asks students to discover and telegraphing what step 4
reveals. They now teach the technique on a car park, and the four
illustrations became runnable demos: a characterisation test catching a
rounding change nobody meant to make, a linter finding three real defects
and none of the design, one class with three reasons to change, and a
dictionary that accepts a vehicle type of "spaceship".

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-08-12 22:36:12 +02:00
.forgejo/workflows Ship the ruff configuration to students, in its own file 2026-08-10 09:07:46 +02:00
appendices Initial commit (Deep Cleaned) 2026-03-25 14:23:48 +01:00
articles Initial commit (Deep Cleaned) 2026-03-25 14:23:48 +01:00
build Teach yield from and itertools in the generators module 2026-08-11 21:46:05 +02:00
demos Simplify the capstone, and stop the slides giving it away 2026-08-12 22:36:12 +02:00
exercises Simplify the capstone, and stop the slides giving it away 2026-08-12 22:36:12 +02:00
extra Put the Python under a linter, and fix what it found 2026-08-09 14:13:09 +02:00
solutions Simplify the capstone, and stop the slides giving it away 2026-08-12 22:36:12 +02:00
src Simplify the capstone, and stop the slides giving it away 2026-08-12 22:36:12 +02:00
tutorial Initial commit (Deep Cleaned) 2026-03-25 14:23:48 +01:00
.gitattributes Add CI release workflow and student bundle pipeline 2026-08-07 21:35:53 +02:00
.gitignore Make the real-project demo actually work, and say what SQLAlchemy needs 2026-08-10 07:46:24 +02:00
.python-version Move the course onto uv 2026-08-07 22:02:51 +02:00
Advanced Python Extra Exercises.docx Initial commit (Deep Cleaned) 2026-03-25 14:23:48 +01:00
Advanced Python Extra Exercises.pdf Initial commit (Deep Cleaned) 2026-03-25 14:23:48 +01:00
Advanced Python Extra.pdf Initial commit (Deep Cleaned) 2026-03-25 14:23:48 +01:00
Advanced Python Extra.pptx Initial commit (Deep Cleaned) 2026-03-25 14:23:48 +01:00
AGENTS.md Drop the A-prefix from the appendix footers 2026-08-11 20:34:09 +02:00
CLAUDE.md Add the railway capstone: refactoring a legacy module into a package 2026-08-12 22:01:04 +02:00
credentials.txt Initial commit (Deep Cleaned) 2026-03-25 14:23:48 +01:00
MAINTAINING.md Describe the new module layout in the three guide files 2026-08-11 20:25:15 +02:00
PRG404-Advanced Python Exercises.pdf Initial commit (Deep Cleaned) 2026-03-25 14:23:48 +01:00
PRG404-Advanced-Python-Exercises_og.pdf Save local changes before Windows reinstall 2026-07-11 18:15:08 +02:00
PRG404-Advanced-Python-Programming_og.pdf Save local changes before Windows reinstall 2026-07-11 18:15:08 +02:00
pyproject.toml Ship the ruff configuration to students, in its own file 2026-08-10 09:07:46 +02:00
README.md Ship the ruff configuration to students, in its own file 2026-08-10 09:07:46 +02:00
resources.txt Initial commit (Deep Cleaned) 2026-03-25 14:23:48 +01:00
ruff.toml Add the railway capstone: refactoring a legacy module into a package 2026-08-12 22:01:04 +02:00
uv.lock Write real exercises and solutions for the thin modules 2026-08-08 10:02:05 +02:00

Advanced Python Programming (PRG404)

Welcome. This bundle contains everything you need for the course : the slides, the lab exercises, runnable example code, reference solutions and a library of background articles. This page explains what is here and how to run it.

This repository is refreshed automatically after every change to the course material, so a git pull always gives you the latest version.

What is in this bundle

  • PRG404-Advanced-Python-Programming.pdf : the course slides. The same deck is also available as .html if you prefer reading in a browser.
  • PRG404-Advanced-Python-Programming-Exercises.pdf : the lab guide, one exercise per module.
  • demos/ : the runnable example programs shown on the slides, one folder per module (for example demos/08-decorators/). A slide that shows a demo names it at the bottom, for example demo06 · bold_tag_decorator, which is the file demos/08-decorators/demo06_bold_tag_decorator.py.
  • solutions/ : reference solutions for the exercises, in case you get stuck or want to compare. Try the exercise first.
  • exercises/ : starter files that a few exercises build on.
  • articles/, appendices/ and tutorial/ : optional background reading, appendix decks (Clean Code, BDD, SQLAlchemy ORM, comprehensions) and step-by-step guides for packaging and publishing to PyPI.
  • extra/ : supplementary material from adjacent courses.

Setting up Python

  1. Install uv, the Python project manager. It can install Python itself, so it is the only thing you install by hand.

    • Windows (PowerShell) :

      powershell -ExecutionPolicy ByPass -c "irm https://astral.sh/uv/install.ps1 | iex"
      
    • macOS or Linux :

      curl -LsSf https://astral.sh/uv/install.sh | sh
      

    Close and reopen your terminal afterwards, then check it with uv --version.

  2. Install the interpreter the course uses :

    uv python install 3.14
    

    This needs no administrator rights and leaves any Python already on the machine alone.

  3. Install an editor. The course demonstrates VS Code with the Microsoft Python extension and the Astral Ruff extension. Any editor works, but the slides assume VS Code.

Creating your own project

You build your own project for the code you write this week, the same way you would at work. The bundle deliberately ships no pyproject.toml, you create one :

uv init course-work
cd course-work
uv add pytest

uv add records the dependency in the pyproject.toml it just created and pins the project to Python 3.14.

The bundle does ship a ruff.toml. That is the linter configuration the course material is written against, so the Ruff extension will not flag the demo files over style choices the course makes on purpose, and it holds the code you write to the same rules.

Running a demo

The demos are plain scripts. Run one by giving its path :

uv run python ../demos/08-decorators/demo06_bold_tag_decorator.py

Running through uv run guarantees the command uses your project's Python and its packages, so you never have to activate an environment by hand.

Running the tests

Several modules ask you to write tests. Run them from your project with :

uv run pytest

Enjoy the course.