Objective & prerequisites
Reason about working directories, relative paths and reproducibility. Prerequisites: basic Python expressions and files; use a disposable local practice folder and fictional data. This shared workshop complements the existing data/AI tracks and does not create a second progress system.
Understand the concept
A relative path is interpreted from the process working directory. The same command can read a different file when launched elsewhere. Absolute paths identify a location but can be machine-specific. Use a documented project root and keep raw/working/output areas separate. File permissions and ownership determine who may read or change a file; a filename is not an authorization boundary.
Worked example
The path test creates a temporary directory, writes one fictional UTF-8 note, reads it back and confirms it is a file. The temporary directory is removed after the test. It does not inspect the user’s home folder or live website.
python3 foundation_labs.py FoundationTests.test_pathsTry it yourself
Run the path test from the extracted pack and describe what would happen if an input were missing. Create a local raw/working/outputs directory sketch without changing system permissions. Record your prediction before running the supplied reference, then compare the observed result and explain any difference.
Worked solution
The round trip returns fictional. A missing required input should produce a clear error before publishing output. Do not create an empty input merely to make the command finish; that would hide a missing-source problem.
Knowledge check
Does a relative filename identify the same file from every directory? Try answering without rereading the example.
Check and explain
No. Record the working-directory assumption or resolve the path against a trusted project location.
Mini-project, mistakes & handover
Produce a short README with the question, exact local command, input meaning, checks and actual results. Include one failure case and its explanation. Never silently turn an exception into a passing result. Mark simulated behavior explicitly, credit the supplied teaching code and identify your own contribution. These activities are unsaved self-practice, not certification.
Authoritative reference
— consulted for the underlying interface/concept. The lesson and fictional examples are original teaching material. Python reference tested with 3.12; designed for 3.10+. Git lab requires Git 2.28+.
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.