Objective & prerequisites
Move from a loose script to a reusable package with a clear command-line boundary. Before starting: basic Python functions, dictionaries, loops, JSON and terminal use. Complete the earlier Git/API/testing workshops if these are unfamiliar. Download and extract the kit into a new practice folder, then open a terminal in the software-kit folder. Python 3.10+ is required; the reference uses only the standard library. Work with the supplied fictional data. These free companion lessons do not change protected course access or award progress or certificates.
python3 --version
python3 -m unittest discover -s tests -vUnderstand the concept
A module is an importable Python file. This regular package is the dch_orders directory with __init__.py, __main__.py and service.py. Running python -m dch_orders executes __main__.py; importing dch_orders exposes the model functions without starting a server or running a CLI. This is a source package, not a published distribution or installed wheel. A virtual environment separates project packages from another project, but does not by itself lock dependencies or isolate untrusted code. This kit has no third-party dependencies and does not require pip installation. Working-directory instructions still matter because the interpreter must locate the source package.
Worked example
From software-kit, python -m dch_orders orders.json reads the bounded UTF-8 file, validates it and prints one JSON summary to stdout. A bad source exits 2 with a generic category on stderr and no result on stdout. __main__.py puts command behavior behind main() and the __name__ guard. Missing files and malformed JSON are reported as rejected input. It never overwrites the source or writes an output unless the learner explicitly redirects stdout.
python3 -m dch_orders orders.json
python3 -m dch_orders orders-invalid.json
python3 -m unittest discover -s tests -vTry it yourself
Create a virtual environment in your practice directory, run the CLI with the valid and invalid fixtures, then invoke it from a different directory and explain the result. Capture stderr separately without replacing your source. Do not install the teaching package globally. Write your expected outcome before running your implementation. Keep the supplied solution unchanged so that you can compare your own reasoning with it.
Worked solution
On macOS/Linux use python3 -m venv .venv followed by .venv/bin/python -m dch_orders orders.json. On Windows use py -m venv .venv followed by .venv\Scripts\python.exe -m dch_orders orders.json. Run these inside software-kit. The valid summary totals 40000 cents and returns 0; invalid duplicates return 2. If the source directory is not importable from the new working directory, Python cannot find the package. A future wheel would require explicit distribution metadata/build tooling, which is not supplied or claimed here.
Knowledge check
Does adding an __init__.py file publish or install your package?
Check and explain
No. It makes this source directory a regular package when its parent is importable. Distribution building, installation and publishing are separate operations.
Evidence & common mistakes
Record the exact command, Python version, observed output and one rejected input. Explain what each check establishes and what it leaves untested. Do not remove validation merely to obtain a passing result. A local passing suite is evidence for these fixtures, not proof of production readiness. Credit the teaching reference and distinguish your own changes. The kit includes an exercise worksheet, a separate worked-solutions document, an API contract, expected results and a capstone rubric.
Authoritative reference
— official reference for the underlying interface. Lesson prose and fictional order examples are original. The teaching HTTP service is loopback-only, stateless and not suitable for production or uploading as a running Aruba service. No cloud account, paid API or registration is required.
Try the activity before reading its reference. Keep your sources, commands and assumptions with your work. Companion activities are unsaved self-practice and do not award a certificate or change lesson progress.