CoursePython from Scratch to Intermediate · Module 11: Capstone · part 74 of 75
Part 74 · Module 11: Capstone

Lab: One command for the shelf each morning

33 min read·14 Oct 2026
Module 11 · Lab · About 90 minutes · Needs: Modules 1 to 10, and the Module 10 lab (the booknook folder in your Drive, with tools.py and tests/)

What you are building

PYTHON -M BOOKNOOK report overdue lend return __main__.py reads the command report.py writes the report models storage tools fees dates earlier labs' modules, unchanged plus tests/test_cli.py and README.md
Four commands (white) reach two new modules (blue), built on the earlier labs' modules (grey), which this lab never changes.

Real projects outlive the tools they were written with. The Python Software Foundation's page "Sunsetting Python 2" (python.org, https://www.python.org/doc/sunset-python-2/) announced that Python 2 would get no more fixes after 1 January 2020. Code written for it had to be moved to Python 3, and the projects that moved most easily were the ones that were organised into modules and had tests to prove each change.

Booknook is now that kind of project. Amira's last request is "Give me one command each morning." This lab adds a command-line tool: a program you run by typing its name and a few words, with no notebook needed.

text
python -m booknook report
python -m booknook overdue
python -m booknook lend B16 M02
python -m booknook return L41

Two new modules do the work, built only on the earlier ones: report.py writes the morning report, and __main__.py reads the command. A new test file checks every command, and a README.md tells Amira how to run it.

Open a new Colab notebook, call it module-11-lab.ipynb, and run each cell in order.

The rest of this part opens with an account

Signing up is free and takes one email. Nothing to pay, and nothing renews.