- This repo is a chaptered Python learning codebase, not a single app/service; each top-level numbered folder (
01_native_datatypes...15_testing) is mostly independent examples. README.mdis the canonical map of chapter intent and file-level examples; use it first to locate the right script before editing.- Most scripts are designed for direct execution and demonstration output (prints, inline calls), not reusable package APIs.
- Common pattern: many files expose small demo functions, then dispatch from
if __name__ == '__main__'usingsys.argv[1]andlocals()/globals()(example:01_native_datatypes/02-numeric-types.py,11_async/07-net-server.py). __doc__is frequently used as in-file theory notes; preserve and extend this style when adding educational examples (example:04_decorators/01-debug-print.py).15_testing/testing.pyprovides core demo functions (rle,sort) consumed by nearby test/demo files.
- Install deps from root:
python3 -m pip install -r requirements.txt
- Run a chapter script directly from root (or its directory), e.g.:
python3 11_async/07-net-server.py square_server
- Run unittest example (from
15_testing/so local importfrom testing import ...resolves):python3 -m unittest 02-unittest.py
- Run pytest property examples:
python3 -m pytest 15_testing/04-property.py
- TCP demo flow is coupled by host/port
127.0.0.1:10001:- server:
11_async/07-net-server.pyor11_async/08-async-server.pyor11_async/09-async-server2.py - client:
11_async/06-net-client.py
- server:
- Module/package demo flow:
14_modules/02-packages.pyimportssmall_package.package_fileand demonstrates lazy import viaimportlib.
- File-IO iterator demo expects relative files in
10_iterators/(file1.txt,file2.txt) in10_iterators/07-io.py.
- Prefer small, single-topic educational scripts over large abstractions.
- Keep examples executable with minimal setup; avoid introducing framework scaffolding.
- When adding examples, follow existing naming style (
NN-topic.py) inside the relevant chapter folder. - Avoid breaking relative-import assumptions in chapter demos (many imports are intentionally local-directory based).
- Preserve demonstrative print-based output unless the file already uses tests/assertions.
- Confirm target chapter/file intent in
README.md. - Verify whether the file is a standalone demo, a test module, or a helper module (
15_testing/testing.py). - If editing
11_asyncor10_iterators, check related peer files that provide input/client behavior. - Run the narrowest relevant command (single script or single test file), not full-repo test sweeps.