Python Craft

From a script to a project

Your code runs. It runs from one directory, on one machine, with one set of packages you cannot quite remember installing. This is the part where it becomes a thing you can hand over: installable, runnable from anywhere, checked by one command, and documented well enough that nobody has to ask you.

Modules
7
Drills
13
Build steps
21
Time
~10h

Walk out with

A working script turned into an installed, tested, typed, configurable package another developer can clone and extend — behaviour unchanged.

What you'll do

01

Environments and imports

Which Python is running, and which file it actually loads.

02

The file that makes it real

Metadata, an editable install, a command you can run.

03

Checks and clear interfaces

One command that passes or fails, and honest types.

04

Onto somebody else's machine

Arguments, config, logging, and a README that works.

What you get

Skills that stick

Every project mixes short lessons, focused drills and real build steps, so you finish with working code and the judgement behind it.

You will practise

  • Say which file an import actually loads
  • Read a version constraint
  • Say which value wins: default, env, or flag
  • Name whose job a complaint is

Afterwards you can

  • Explain why "works on my machine" happens
  • Lay out and install a real project
  • Make every check runnable with one command
  • Hand a codebase to somebody else

Modules

Step by step

Each module builds on the last. Read a short lesson, drill it until it's second nature, then put it to work.

  1. 1

    Which Python is running?

    ~1h

    One import succeeds in one terminal and fails in another, with no file changed.

    • LessonThere is no such thing as "Python"14 min
    • Build stepBuild one and look inside it12 min
    • DrillWhich Python is that11 min
    • LessonSay what you need15 min
    • DrillRead a dependency line11 min
    • LessonHow much project is enough10 min
  2. 2

    Where the package lives

    ~1h

    A test that passes against the wrong copy, and the layout that prevents it.

    • LessonWhich copy wins15 min
    • DrillSay which file the import loads13 min
    • Build stepMove it to a src layout14 min
    • Build stepPoint the tests at the installed package13 min
    • DrillName the defect in the repository12 min
  3. 3

    The file that says what this is

    ~1h

    One file turns a folder into a project you can install and run.

    • LessonOne file, three jobs14 min
    • DrillWhich table states this10 min
    • Build stepFill the file in15 min
    • DrillSpot the broken line12 min
    • Build stepBuild it and look at what came out12 min
  4. 4

    Checks you can run again

    ~59 min

    Four tools with opinions, and one number that decides whether the gate passed.

    • LessonFour things that can object14 min
    • DrillWhose job is this complaint12 min
    • DrillRead the verdict10 min
    • Build stepMake it one command15 min
    • LessonWhat the gate is for8 min
  5. 5

    Say what goes in and out

    ~40 min

    A signature that is a guess, and the four annotations that make it a contract.

    • LessonA signature that is a guess14 min
    • DrillWhich signature says that11 min
    • Build stepRun the checker and fix the interface15 min
  6. 6

    Run it somewhere else

    ~2h

    Arguments in, configuration in, diagnostics out — and nothing you could not publish.

    • LessonThe contract on the command line14 min
    • DrillWhat the parser hands you12 min
    • Build stepGive it a real command line15 min
    • LessonConfiguration that travels9 min
    • DrillWhich value wins11 min
    • LessonCould you publish this tomorrow?9 min
    • DrillCould you publish this tomorrow10 min
    • LessonPrint, or log13 min
    • DrillHow much of this comes out11 min
    • Build stepWire configuration and logging16 min
  7. 7

    Turn it into a project

    ~3h

    Two hundred lines that work and cannot be handed over. Same behaviour, out the far side.

    • Build stepRead it, and write down what is wrong16 min
    • Build stepMake it a package22 min
    • Build stepGive it metadata and a way in18 min
    • Build stepTest the decision, not the printing11 min
    • Build stepChain them into one verdict11 min
    • Build stepAnnotate the public surface16 min
    • Build stepGive it a command line9 min
    • Build stepLet the machine configure it8 min
    • Build stepPut the diagnostics on a level9 min
    • Build stepWrite the documentation13 min
    • Build stepProve it on an empty machine12 min
    • Build stepAdd one thing nobody showed you20 min

Ready when you are.

Work through it at your own pace and pick up right where you left off.