Python Craft Ladder

A track of P4 · Python & DS Engineering Craft.

A graded ladder from idiomatic Python through vectorisation to tested, packaged code — practising the craft one rung at a time.

Two scripts do the same job. One is forty lines of loops, flags and temporary variables; the other is eight lines and reads almost like the task description. Both pass the tests today — but what do the extra thirty-two lines cost you? Thirty-two more places for a bug to hide, thirty-two more lines a colleague must hold in their head, and a dozen more spots where next month's change can go wrong. Yet the eight-line version has costs of its own if it is merely clever rather than clear. Knowing which eight lines — and when forty honest lines are actually the right call — is the craft this track trains.

The training happens by doing, on a graded ladder of exercises you climb right in the browser (your code runs in Pyodide, a full Python in the page — nothing leaves your machine). Rung one rewrites laborious code into idiomatic Python; rung two flips the direction and makes you build the convenient tools from scratch, so you know what the idioms are hiding; rung three hands you working-but-ugly code to clean up; and a free-form rung asks you to explain your choices, because craft you cannot articulate is luck. An explorer rung has you predict where a naive and an idiomatic version disagree before running them, and the senior rung ends the climb at production grade. Each exercise checks your code against visible tests you can read — then hidden ones that catch the edge cases you hoped nobody would mention.

The second ladder takes the same climb onto real, inconvenient data: files that do not parse cleanly, columns that lie about their types, and the dataframe habits that turn a page of loops into a line of intent. This is the layer between knowing Python and engineering with it — the difference between code that runs and code you would be happy to be reviewed on. Every track after this one assumes you write the second kind; a few hours on these rungs is where that assumption becomes true.

IdiomsPythonic beats laboriousFrom scratchbuild what idioms hideRefactorugly code, cleaned upReal datamessy files, tamed
Two graded ladders: master the idioms, earn them by building their innards, then apply the craft to data that fights back.