DataCareerHub
Explore learning
← Shared foundationsFree companion · 25 minute suggested activity

Navigate paths and preserve source files

Command line & Linux · Shared foundation workshop · Reason about working directories, relative paths and reproducibility.

Learn → Try → ExplainReviewed 2026-10-15
01

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.

02

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.

03

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_paths
04

Try 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.

06

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.

08

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.

09

Authoritative reference

Read the official 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+.

Make the reasoning yours.

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.

Resume guidance and examples are for learning and preparation only. They do not guarantee interviews, a job offer or employment.

Public registration, payments and new paid enrolment remain disabled. These free resources do not grant access to protected course modules.

Learner dashboard ↗ · Ask a question ↗