Small Group Tutorials

Here to help students catch up, keep up, and move ahead. Book a consultation here.

How to Master Python pathlib.Path.is_junction in Punggol Tuition

HDB flats in Punggol at sunset

A folder can open like an ordinary directory while actually redirecting traversal through a Windows junction. That difference matters when a learner writes a backup scanner, deletion preview or project indexer.

Python pathlib.Path.is_junction() returns True when a concrete path points to a junction and False for other file types. The method was added in Python 3.12, and the current documentation states that only Windows supports junctions.

This guide teaches junction identity, ordinary directories, symbolic links, mount points, platform-aware tests, recursive traversal decisions and safe diagnostics without treating every redirected path as the same mechanism.

Punggol families can use this guide in short sessions around homework, CCAs and rest. The examples are proposed learning activities. They do not claim a physical tuition branch, timetable, fee, class size, school relationship or guaranteed result.

Use disposable data and repositories, preserve backups and check version-sensitive details against the linked primary source. Current documentation settles a technical contract; observation and explanation turn that contract into usable knowledge.

Find your next learning step

Choose the route that matches the present difficulty. A complete course can follow the index in order; a repair session can begin at the first unstable distinction.

Build the model

Chapters 1–4. Build the junction, directory and path-classification model.

Read the contract

Chapters 5–8. Read the Windows-only and Python-version contract precisely.

Test the boundary

Chapters 9–12. Create disposable positive and negative fixtures safely.

Diagnose and repair

Chapters 13–16. Diagnose platform, traversal and reparse-point assumptions.

Transfer with judgment

Chapters 17–20. Choose is_junction, is_symlink, is_mount or is_dir by job.

Open the full chapter index · Jump to capstone practice · Use the How Studying Works hub · Read the primary technical source

CHAPTER 1 OF 20 · Build the model

1. A junction is a specific Windows path object

Back to contents

Path.is_junction asks whether the concrete path points to a Windows junction, not whether it merely names a directory. That is the invariant to preserve when names, data or surrounding project details change.

The label describes a filesystem mechanism rather than a visual folder appearance. The useful question is not “Which line should I copy?” but “Which state, value or rendering decision does this operation control?” Answering that question prevents a correct-looking result from hiding a wrong mental model.

The most revealing near-miss is calling every directory alias a junction. A learner should predict the result first, run the smallest safe case, label the observation and explain the earliest point where the prediction diverges. This turns an error into evidence rather than a verdict on ability.

Core worked example

from pathlib import Path
print(Path(r'C:\work\shared').is_junction())

Explained result. The result is True only when the path is a junction on a supporting Windows system. The explanation should identify the input, the governing rule, the observable outcome and one boundary that would change the conclusion. If any of those four parts is missing, reduce the example and trace it again.

Read the trace, not just the last line

Trace pathname, platform support, filesystem lookup and Boolean classification. Write the trace as a sequence of labelled states. For Python pathlib.Path.is_junction, inspect resolved pathnames, stat identities, exception types and before-and-after directory listings; a single final value can hide the mechanism that produced it.

For “A junction is a specific Windows path object”, separate contract from coincidence. The contract is “Path.is_junction asks whether the concrete path points to a Windows junction, not whether it merely names a directory.” and comes from the primary specification or manual. Coincidence is what happened on one machine, font, filesystem or repository. Record both, then use “Create one ordinary directory and one junction in a disposable Windows workspace.” to decide whether another observation challenges the model or merely reflects the environment.

Four purposeful transfer cases

Case 1: homework export guard. Model “A junction is a specific Windows path object” with an input document, two path spellings and a proposed output. Before touching a tool, state which part of the case corresponds to the input, why “Path.is_junction asks whether the concrete path points to a Windows junction, not whether it merely names a directory.” should remain invariant and what observation would expose calling every directory alias a junction.

Reasoned route. Begin with “Path.is_junction asks whether the concrete path points to a Windows junction, not whether it merely names a directory.” Apply this procedure: Create one ordinary directory and one junction in a disposable Windows workspace. For the homework export guard, introduce one controlled variation that exposes calling every directory alias a junction. The result is True only when the path is a junction on a supporting Windows system. A complete answer explains why the near-miss fails, names the evidence that distinguishes it from the corrected case and transfers the rule without relying on the original variable names.

Case 2: photo-library alias check. Contrast “A junction is a specific Windows path object” with original files, hard-link aliases and independent copies. Before touching a tool, state which part of the case corresponds to the input, why “Path.is_junction asks whether the concrete path points to a Windows junction, not whether it merely names a directory.” should remain invariant and what observation would expose calling every directory alias a junction.

Reasoned route. Begin with “Path.is_junction asks whether the concrete path points to a Windows junction, not whether it merely names a directory.” Apply this procedure: Create one ordinary directory and one junction in a disposable Windows workspace. For the photo-library alias check, introduce one controlled variation that exposes calling every directory alias a junction. The result is True only when the path is a junction on a supporting Windows system. A complete answer explains why the near-miss fails, names the evidence that distinguishes it from the corrected case and transfers the rule without relying on the original variable names.

Case 3: science-data archive. Stress-test “A junction is a specific Windows path object” with raw readings, a symlinked working folder and a missing target. Before touching a tool, state which part of the case corresponds to the input, why “Path.is_junction asks whether the concrete path points to a Windows junction, not whether it merely names a directory.” should remain invariant and what observation would expose calling every directory alias a junction.

Reasoned route. Begin with “Path.is_junction asks whether the concrete path points to a Windows junction, not whether it merely names a directory.” Apply this procedure: Create one ordinary directory and one junction in a disposable Windows workspace. For the science-data archive, introduce one controlled variation that exposes calling every directory alias a junction. The result is True only when the path is a junction on a supporting Windows system. A complete answer explains why the near-miss fails, names the evidence that distinguishes it from the corrected case and transfers the rule without relying on the original variable names.

Case 4: backup verification task. Explain “A junction is a specific Windows path object” with source directories, mounted destinations and privacy-safe diagnostics. Before touching a tool, state which part of the case corresponds to the input, why “Path.is_junction asks whether the concrete path points to a Windows junction, not whether it merely names a directory.” should remain invariant and what observation would expose calling every directory alias a junction.

Reasoned route. Begin with “Path.is_junction asks whether the concrete path points to a Windows junction, not whether it merely names a directory.” Apply this procedure: Create one ordinary directory and one junction in a disposable Windows workspace. For the backup verification task, introduce one controlled variation that exposes calling every directory alias a junction. The result is True only when the path is a junction on a supporting Windows system. A complete answer explains why the near-miss fails, names the evidence that distinguishes it from the corrected case and transfers the rule without relying on the original variable names.

Diagnostic route

  • Model check: draw or list the exact values, objects, paths, characters or repository states before the operation.
  • Boundary check: construct the smallest safe input that reveals calling every directory alias a junction.
  • Evidence check: distinguish a displayed result from ownership, caching, consumption, font behaviour or object type.
  • Repair check: Create one ordinary directory and one junction in a disposable Windows workspace.
  • Transfer check: repeat the rule in a second context and name what remains unchanged.

A parent does not need to memorise Python pathlib.Path.is_junction to support “A junction is a specific Windows path object”. Useful prompts are: “What did you expect?”, “Which state changed first?”, “What evidence tests Path.is_junction asks whether the concrete path points to a Windows junction, not whether it merely names a directory.?”, and “Can you make a smaller example of calling every directory alias a junction?” These questions keep ownership with the learner while making the reasoning visible.

Practice with an explained answer

Task. Classify two folder-looking paths. Write the prediction before running anything. Include one ordinary case and one boundary case, then explain the difference in two causal sentences.

Answer route. The ordinary directory is False; a genuine junction is True. The final output alone earns only partial credit. A strong answer connects it to “Path.is_junction asks whether the concrete path points to a Windows junction, not whether it merely names a directory.”, shows the relevant intermediate evidence and states why calling every directory alias a junction would lead to a different conclusion.

Decision and transfer

Use the precise filesystem category in logs and policy. Prefer the choice whose semantics and failure modes are easiest to explain for the actual job. Shorter syntax is useful only when it preserves that clarity.

Mastery of “A junction is a specific Windows path object” means the learner can predict the ordinary case, recognise calling every directory alias a junction, diagnose the earliest mistaken assumption, recover with “Create one ordinary directory and one junction in a disposable Windows workspace.” and defend this decision: Use the precise filesystem category in logs and policy. Once that causal chain is stable, continue to the next chapter rather than adding repetitions of the same surface exercise.

Previous section · Contents · Next section

CHAPTER 2 OF 20 · Build the model

2. The method was added in Python 3.12

Back to contents

Path.is_junction is part of pathlib from Python 3.12 onward. That is the invariant to preserve when names, data or surrounding project details change.

API availability is a runtime-version question before it is a filesystem question. The useful question is not “Which line should I copy?” but “Which state, value or rendering decision does this operation control?” Answering that question prevents a correct-looking result from hiding a wrong mental model.

The most revealing near-miss is diagnosing AttributeError as a bad path. A learner should predict the result first, run the smallest safe case, label the observation and explain the earliest point where the prediction diverges. This turns an error into evidence rather than a verdict on ability.

Core worked example

import sys
print(sys.version_info[:3])
print(hasattr(__import__('pathlib').Path, 'is_junction'))

Explained result. A supporting runtime exposes the method; older runtimes do not. The explanation should identify the input, the governing rule, the observable outcome and one boundary that would change the conclusion. If any of those four parts is missing, reduce the example and trace it again.

Read the trace, not just the last line

Trace import, attribute lookup and later filesystem call separately. Write the trace as a sequence of labelled states. For Python pathlib.Path.is_junction, inspect resolved pathnames, stat identities, exception types and before-and-after directory listings; a single final value can hide the mechanism that produced it.

For “The method was added in Python 3.12”, separate contract from coincidence. The contract is “Path.is_junction is part of pathlib from Python 3.12 onward.” and comes from the primary specification or manual. Coincidence is what happened on one machine, font, filesystem or repository. Record both, then use “Record the interpreter version and feature presence before running path fixtures.” to decide whether another observation challenges the model or merely reflects the environment.

Four purposeful transfer cases

Case 1: homework export guard. Model “The method was added in Python 3.12” with an input document, two path spellings and a proposed output. Before touching a tool, state which part of the case corresponds to the input, why “Path.is_junction is part of pathlib from Python 3.12 onward.” should remain invariant and what observation would expose diagnosing AttributeError as a bad path.

Reasoned route. Begin with “Path.is_junction is part of pathlib from Python 3.12 onward.” Apply this procedure: Record the interpreter version and feature presence before running path fixtures. For the homework export guard, introduce one controlled variation that exposes diagnosing AttributeError as a bad path. A supporting runtime exposes the method; older runtimes do not. A complete answer explains why the near-miss fails, names the evidence that distinguishes it from the corrected case and transfers the rule without relying on the original variable names.

Case 2: photo-library alias check. Contrast “The method was added in Python 3.12” with original files, hard-link aliases and independent copies. Before touching a tool, state which part of the case corresponds to the input, why “Path.is_junction is part of pathlib from Python 3.12 onward.” should remain invariant and what observation would expose diagnosing AttributeError as a bad path.

Reasoned route. Begin with “Path.is_junction is part of pathlib from Python 3.12 onward.” Apply this procedure: Record the interpreter version and feature presence before running path fixtures. For the photo-library alias check, introduce one controlled variation that exposes diagnosing AttributeError as a bad path. A supporting runtime exposes the method; older runtimes do not. A complete answer explains why the near-miss fails, names the evidence that distinguishes it from the corrected case and transfers the rule without relying on the original variable names.

Case 3: science-data archive. Stress-test “The method was added in Python 3.12” with raw readings, a symlinked working folder and a missing target. Before touching a tool, state which part of the case corresponds to the input, why “Path.is_junction is part of pathlib from Python 3.12 onward.” should remain invariant and what observation would expose diagnosing AttributeError as a bad path.

Reasoned route. Begin with “Path.is_junction is part of pathlib from Python 3.12 onward.” Apply this procedure: Record the interpreter version and feature presence before running path fixtures. For the science-data archive, introduce one controlled variation that exposes diagnosing AttributeError as a bad path. A supporting runtime exposes the method; older runtimes do not. A complete answer explains why the near-miss fails, names the evidence that distinguishes it from the corrected case and transfers the rule without relying on the original variable names.

Case 4: backup verification task. Explain “The method was added in Python 3.12” with source directories, mounted destinations and privacy-safe diagnostics. Before touching a tool, state which part of the case corresponds to the input, why “Path.is_junction is part of pathlib from Python 3.12 onward.” should remain invariant and what observation would expose diagnosing AttributeError as a bad path.

Reasoned route. Begin with “Path.is_junction is part of pathlib from Python 3.12 onward.” Apply this procedure: Record the interpreter version and feature presence before running path fixtures. For the backup verification task, introduce one controlled variation that exposes diagnosing AttributeError as a bad path. A supporting runtime exposes the method; older runtimes do not. A complete answer explains why the near-miss fails, names the evidence that distinguishes it from the corrected case and transfers the rule without relying on the original variable names.

Diagnostic route

  • Model check: draw or list the exact values, objects, paths, characters or repository states before the operation.
  • Boundary check: construct the smallest safe input that reveals diagnosing AttributeError as a bad path.
  • Evidence check: distinguish a displayed result from ownership, caching, consumption, font behaviour or object type.
  • Repair check: Record the interpreter version and feature presence before running path fixtures.
  • Transfer check: repeat the rule in a second context and name what remains unchanged.

A parent does not need to memorise Python pathlib.Path.is_junction to support “The method was added in Python 3.12”. Useful prompts are: “What did you expect?”, “Which state changed first?”, “What evidence tests Path.is_junction is part of pathlib from Python 3.12 onward.?”, and “Can you make a smaller example of diagnosing AttributeError as a bad path?” These questions keep ownership with the learner while making the reasoning visible.

Practice with an explained answer

Task. Write a compatibility check. Write the prediction before running anything. Include one ordinary case and one boundary case, then explain the difference in two causal sentences.

Answer route. Use hasattr only to choose a documented fallback or version error, not to invent junction detection. The final output alone earns only partial credit. A strong answer connects it to “Path.is_junction is part of pathlib from Python 3.12 onward.”, shows the relevant intermediate evidence and states why diagnosing AttributeError as a bad path would lead to a different conclusion.

Decision and transfer

Set and test a declared Python version floor. Prefer the choice whose semantics and failure modes are easiest to explain for the actual job. Shorter syntax is useful only when it preserves that clarity.

Mastery of “The method was added in Python 3.12” means the learner can predict the ordinary case, recognise diagnosing AttributeError as a bad path, diagnose the earliest mistaken assumption, recover with “Record the interpreter version and feature presence before running path fixtures.” and defend this decision: Set and test a declared Python version floor. Once that causal chain is stable, continue to the next chapter rather than adding repetitions of the same surface exercise.

Previous section · Contents · Next section

CHAPTER 3 OF 20 · Build the model

3. Only Windows currently supports junctions

Back to contents

The Python documentation states that junction support is currently Windows-only. That is the invariant to preserve when names, data or surrounding project details change.

Similar navigation effects can come from different platform mechanisms. The useful question is not “Which line should I copy?” but “Which state, value or rendering decision does this operation control?” Answering that question prevents a correct-looking result from hiding a wrong mental model.

The most revealing near-miss is treating a Linux bind mount as a Windows junction. A learner should predict the result first, run the smallest safe case, label the observation and explain the earliest point where the prediction diverges. This turns an error into evidence rather than a verdict on ability.

Core worked example

from pathlib import Path
print(Path('.').is_junction())

Explained result. On a non-Windows system an ordinary path does not become a junction and the result is False. The explanation should identify the input, the governing rule, the observable outcome and one boundary that would change the conclusion. If any of those four parts is missing, reduce the example and trace it again.

Read the trace, not just the last line

Trace operating system, supported concept and returned classification. Write the trace as a sequence of labelled states. For Python pathlib.Path.is_junction, inspect resolved pathnames, stat identities, exception types and before-and-after directory listings; a single final value can hide the mechanism that produced it.

For “Only Windows currently supports junctions”, separate contract from coincidence. The contract is “The Python documentation states that junction support is currently Windows-only.” and comes from the primary specification or manual. Coincidence is what happened on one machine, font, filesystem or repository. Record both, then use “Run the same negative fixture on the available platform and label the platform.” to decide whether another observation challenges the model or merely reflects the environment.

Four purposeful transfer cases

Case 1: homework export guard. Model “Only Windows currently supports junctions” with an input document, two path spellings and a proposed output. Before touching a tool, state which part of the case corresponds to the input, why “The Python documentation states that junction support is currently Windows-only.” should remain invariant and what observation would expose treating a Linux bind mount as a Windows junction.

Reasoned route. Begin with “The Python documentation states that junction support is currently Windows-only.” Apply this procedure: Run the same negative fixture on the available platform and label the platform. For the homework export guard, introduce one controlled variation that exposes treating a Linux bind mount as a Windows junction. On a non-Windows system an ordinary path does not become a junction and the result is False. A complete answer explains why the near-miss fails, names the evidence that distinguishes it from the corrected case and transfers the rule without relying on the original variable names.

Case 2: photo-library alias check. Contrast “Only Windows currently supports junctions” with original files, hard-link aliases and independent copies. Before touching a tool, state which part of the case corresponds to the input, why “The Python documentation states that junction support is currently Windows-only.” should remain invariant and what observation would expose treating a Linux bind mount as a Windows junction.

Reasoned route. Begin with “The Python documentation states that junction support is currently Windows-only.” Apply this procedure: Run the same negative fixture on the available platform and label the platform. For the photo-library alias check, introduce one controlled variation that exposes treating a Linux bind mount as a Windows junction. On a non-Windows system an ordinary path does not become a junction and the result is False. A complete answer explains why the near-miss fails, names the evidence that distinguishes it from the corrected case and transfers the rule without relying on the original variable names.

Case 3: science-data archive. Stress-test “Only Windows currently supports junctions” with raw readings, a symlinked working folder and a missing target. Before touching a tool, state which part of the case corresponds to the input, why “The Python documentation states that junction support is currently Windows-only.” should remain invariant and what observation would expose treating a Linux bind mount as a Windows junction.

Reasoned route. Begin with “The Python documentation states that junction support is currently Windows-only.” Apply this procedure: Run the same negative fixture on the available platform and label the platform. For the science-data archive, introduce one controlled variation that exposes treating a Linux bind mount as a Windows junction. On a non-Windows system an ordinary path does not become a junction and the result is False. A complete answer explains why the near-miss fails, names the evidence that distinguishes it from the corrected case and transfers the rule without relying on the original variable names.

Case 4: backup verification task. Explain “Only Windows currently supports junctions” with source directories, mounted destinations and privacy-safe diagnostics. Before touching a tool, state which part of the case corresponds to the input, why “The Python documentation states that junction support is currently Windows-only.” should remain invariant and what observation would expose treating a Linux bind mount as a Windows junction.

Reasoned route. Begin with “The Python documentation states that junction support is currently Windows-only.” Apply this procedure: Run the same negative fixture on the available platform and label the platform. For the backup verification task, introduce one controlled variation that exposes treating a Linux bind mount as a Windows junction. On a non-Windows system an ordinary path does not become a junction and the result is False. A complete answer explains why the near-miss fails, names the evidence that distinguishes it from the corrected case and transfers the rule without relying on the original variable names.

Diagnostic route

  • Model check: draw or list the exact values, objects, paths, characters or repository states before the operation.
  • Boundary check: construct the smallest safe input that reveals treating a Linux bind mount as a Windows junction.
  • Evidence check: distinguish a displayed result from ownership, caching, consumption, font behaviour or object type.
  • Repair check: Run the same negative fixture on the available platform and label the platform.
  • Transfer check: repeat the rule in a second context and name what remains unchanged.

A parent does not need to memorise Python pathlib.Path.is_junction to support “Only Windows currently supports junctions”. Useful prompts are: “What did you expect?”, “Which state changed first?”, “What evidence tests The Python documentation states that junction support is currently Windows-only.?”, and “Can you make a smaller example of treating a Linux bind mount as a Windows junction?” These questions keep ownership with the learner while making the reasoning visible.

Practice with an explained answer

Task. Explain a False result on POSIX. Write the prediction before running anything. Include one ordinary case and one boundary case, then explain the difference in two causal sentences.

Answer route. It confirms only that this path is not reported as a Windows junction; it does not classify every possible mount mechanism. The final output alone earns only partial credit. A strong answer connects it to “The Python documentation states that junction support is currently Windows-only.”, shows the relevant intermediate evidence and states why treating a Linux bind mount as a Windows junction would lead to a different conclusion.

Decision and transfer

Branch platform-specific work explicitly. Prefer the choice whose semantics and failure modes are easiest to explain for the actual job. Shorter syntax is useful only when it preserves that clarity.

Mastery of “Only Windows currently supports junctions” means the learner can predict the ordinary case, recognise treating a Linux bind mount as a Windows junction, diagnose the earliest mistaken assumption, recover with “Run the same negative fixture on the available platform and label the platform.” and defend this decision: Branch platform-specific work explicitly. Once that causal chain is stable, continue to the next chapter rather than adding repetitions of the same surface exercise.

Previous section · Contents · Next section

CHAPTER 4 OF 20 · Build the model

4. An ordinary directory is not a junction

Back to contents

A normal directory remains False even though programs can traverse into it. That is the invariant to preserve when names, data or surrounding project details change.

Traversal capability is broader than junction classification. The useful question is not “Which line should I copy?” but “Which state, value or rendering decision does this operation control?” Answering that question prevents a correct-looking result from hiding a wrong mental model.

The most revealing near-miss is using directory behaviour as proof of junction identity. A learner should predict the result first, run the smallest safe case, label the observation and explain the earliest point where the prediction diverges. This turns an error into evidence rather than a verdict on ability.

Core worked example

from pathlib import Path
p=Path('ordinary-folder')
p.mkdir(exist_ok=True)
print(p.is_dir(), p.is_junction())

Explained result. The controlled ordinary directory reports is_dir True and is_junction False. The explanation should identify the input, the governing rule, the observable outcome and one boundary that would change the conclusion. If any of those four parts is missing, reduce the example and trace it again.

Read the trace, not just the last line

Trace creation, directory classification and junction classification. Write the trace as a sequence of labelled states. For Python pathlib.Path.is_junction, inspect resolved pathnames, stat identities, exception types and before-and-after directory listings; a single final value can hide the mechanism that produced it.

For “An ordinary directory is not a junction”, separate contract from coincidence. The contract is “A normal directory remains False even though programs can traverse into it.” and comes from the primary specification or manual. Coincidence is what happened on one machine, font, filesystem or repository. Record both, then use “Create the directory in a temporary workspace and remove it through the workspace lifecycle.” to decide whether another observation challenges the model or merely reflects the environment.

Four purposeful transfer cases

Case 1: homework export guard. Model “An ordinary directory is not a junction” with an input document, two path spellings and a proposed output. Before touching a tool, state which part of the case corresponds to the input, why “A normal directory remains False even though programs can traverse into it.” should remain invariant and what observation would expose using directory behaviour as proof of junction identity.

Reasoned route. Begin with “A normal directory remains False even though programs can traverse into it.” Apply this procedure: Create the directory in a temporary workspace and remove it through the workspace lifecycle. For the homework export guard, introduce one controlled variation that exposes using directory behaviour as proof of junction identity. The controlled ordinary directory reports is_dir True and is_junction False. A complete answer explains why the near-miss fails, names the evidence that distinguishes it from the corrected case and transfers the rule without relying on the original variable names.

Case 2: photo-library alias check. Contrast “An ordinary directory is not a junction” with original files, hard-link aliases and independent copies. Before touching a tool, state which part of the case corresponds to the input, why “A normal directory remains False even though programs can traverse into it.” should remain invariant and what observation would expose using directory behaviour as proof of junction identity.

Reasoned route. Begin with “A normal directory remains False even though programs can traverse into it.” Apply this procedure: Create the directory in a temporary workspace and remove it through the workspace lifecycle. For the photo-library alias check, introduce one controlled variation that exposes using directory behaviour as proof of junction identity. The controlled ordinary directory reports is_dir True and is_junction False. A complete answer explains why the near-miss fails, names the evidence that distinguishes it from the corrected case and transfers the rule without relying on the original variable names.

Case 3: science-data archive. Stress-test “An ordinary directory is not a junction” with raw readings, a symlinked working folder and a missing target. Before touching a tool, state which part of the case corresponds to the input, why “A normal directory remains False even though programs can traverse into it.” should remain invariant and what observation would expose using directory behaviour as proof of junction identity.

Reasoned route. Begin with “A normal directory remains False even though programs can traverse into it.” Apply this procedure: Create the directory in a temporary workspace and remove it through the workspace lifecycle. For the science-data archive, introduce one controlled variation that exposes using directory behaviour as proof of junction identity. The controlled ordinary directory reports is_dir True and is_junction False. A complete answer explains why the near-miss fails, names the evidence that distinguishes it from the corrected case and transfers the rule without relying on the original variable names.

Case 4: backup verification task. Explain “An ordinary directory is not a junction” with source directories, mounted destinations and privacy-safe diagnostics. Before touching a tool, state which part of the case corresponds to the input, why “A normal directory remains False even though programs can traverse into it.” should remain invariant and what observation would expose using directory behaviour as proof of junction identity.

Reasoned route. Begin with “A normal directory remains False even though programs can traverse into it.” Apply this procedure: Create the directory in a temporary workspace and remove it through the workspace lifecycle. For the backup verification task, introduce one controlled variation that exposes using directory behaviour as proof of junction identity. The controlled ordinary directory reports is_dir True and is_junction False. A complete answer explains why the near-miss fails, names the evidence that distinguishes it from the corrected case and transfers the rule without relying on the original variable names.

Diagnostic route

  • Model check: draw or list the exact values, objects, paths, characters or repository states before the operation.
  • Boundary check: construct the smallest safe input that reveals using directory behaviour as proof of junction identity.
  • Evidence check: distinguish a displayed result from ownership, caching, consumption, font behaviour or object type.
  • Repair check: Create the directory in a temporary workspace and remove it through the workspace lifecycle.
  • Transfer check: repeat the rule in a second context and name what remains unchanged.

A parent does not need to memorise Python pathlib.Path.is_junction to support “An ordinary directory is not a junction”. Useful prompts are: “What did you expect?”, “Which state changed first?”, “What evidence tests A normal directory remains False even though programs can traverse into it.?”, and “Can you make a smaller example of using directory behaviour as proof of junction identity?” These questions keep ownership with the learner while making the reasoning visible.

Practice with an explained answer

Task. Predict both Booleans. Write the prediction before running anything. Include one ordinary case and one boundary case, then explain the difference in two causal sentences.

Answer route. They are True and False respectively in the ordinary case. The final output alone earns only partial credit. A strong answer connects it to “A normal directory remains False even though programs can traverse into it.”, shows the relevant intermediate evidence and states why using directory behaviour as proof of junction identity would lead to a different conclusion.

Decision and transfer

Ask the narrow classification question needed by the application. Prefer the choice whose semantics and failure modes are easiest to explain for the actual job. Shorter syntax is useful only when it preserves that clarity.

Mastery of “An ordinary directory is not a junction” means the learner can predict the ordinary case, recognise using directory behaviour as proof of junction identity, diagnose the earliest mistaken assumption, recover with “Create the directory in a temporary workspace and remove it through the workspace lifecycle.” and defend this decision: Ask the narrow classification question needed by the application. Once that causal chain is stable, continue to the next chapter rather than adding repetitions of the same surface exercise.

Previous section · Contents · Next section

CHAPTER 5 OF 20 · Read the contract

5. A regular file is not a junction

Back to contents

A normal file does not satisfy the junction predicate. That is the invariant to preserve when names, data or surrounding project details change.

Predicates divide path types rather than certify generic existence. The useful question is not “Which line should I copy?” but “Which state, value or rendering decision does this operation control?” Answering that question prevents a correct-looking result from hiding a wrong mental model.

The most revealing near-miss is assuming every reparse-aware predicate identifies any path. A learner should predict the result first, run the smallest safe case, label the observation and explain the earliest point where the prediction diverges. This turns an error into evidence rather than a verdict on ability.

Core worked example

from pathlib import Path
p=Path('note.txt'); p.write_text('fixture')
print(p.is_junction())

Explained result. The regular file returns False. The explanation should identify the input, the governing rule, the observable outcome and one boundary that would change the conclusion. If any of those four parts is missing, reduce the example and trace it again.

Read the trace, not just the last line

Trace file creation and the negative junction test. Write the trace as a sequence of labelled states. For Python pathlib.Path.is_junction, inspect resolved pathnames, stat identities, exception types and before-and-after directory listings; a single final value can hide the mechanism that produced it.

For “A regular file is not a junction”, separate contract from coincidence. The contract is “A normal file does not satisfy the junction predicate.” and comes from the primary specification or manual. Coincidence is what happened on one machine, font, filesystem or repository. Record both, then use “Use a temporary file beside the directory fixture.” to decide whether another observation challenges the model or merely reflects the environment.

Four purposeful transfer cases

Case 1: homework export guard. Model “A regular file is not a junction” with an input document, two path spellings and a proposed output. Before touching a tool, state which part of the case corresponds to the input, why “A normal file does not satisfy the junction predicate.” should remain invariant and what observation would expose assuming every reparse-aware predicate identifies any path.

Reasoned route. Begin with “A normal file does not satisfy the junction predicate.” Apply this procedure: Use a temporary file beside the directory fixture. For the homework export guard, introduce one controlled variation that exposes assuming every reparse-aware predicate identifies any path. The regular file returns False. A complete answer explains why the near-miss fails, names the evidence that distinguishes it from the corrected case and transfers the rule without relying on the original variable names.

Case 2: photo-library alias check. Contrast “A regular file is not a junction” with original files, hard-link aliases and independent copies. Before touching a tool, state which part of the case corresponds to the input, why “A normal file does not satisfy the junction predicate.” should remain invariant and what observation would expose assuming every reparse-aware predicate identifies any path.

Reasoned route. Begin with “A normal file does not satisfy the junction predicate.” Apply this procedure: Use a temporary file beside the directory fixture. For the photo-library alias check, introduce one controlled variation that exposes assuming every reparse-aware predicate identifies any path. The regular file returns False. A complete answer explains why the near-miss fails, names the evidence that distinguishes it from the corrected case and transfers the rule without relying on the original variable names.

Case 3: science-data archive. Stress-test “A regular file is not a junction” with raw readings, a symlinked working folder and a missing target. Before touching a tool, state which part of the case corresponds to the input, why “A normal file does not satisfy the junction predicate.” should remain invariant and what observation would expose assuming every reparse-aware predicate identifies any path.

Reasoned route. Begin with “A normal file does not satisfy the junction predicate.” Apply this procedure: Use a temporary file beside the directory fixture. For the science-data archive, introduce one controlled variation that exposes assuming every reparse-aware predicate identifies any path. The regular file returns False. A complete answer explains why the near-miss fails, names the evidence that distinguishes it from the corrected case and transfers the rule without relying on the original variable names.

Case 4: backup verification task. Explain “A regular file is not a junction” with source directories, mounted destinations and privacy-safe diagnostics. Before touching a tool, state which part of the case corresponds to the input, why “A normal file does not satisfy the junction predicate.” should remain invariant and what observation would expose assuming every reparse-aware predicate identifies any path.

Reasoned route. Begin with “A normal file does not satisfy the junction predicate.” Apply this procedure: Use a temporary file beside the directory fixture. For the backup verification task, introduce one controlled variation that exposes assuming every reparse-aware predicate identifies any path. The regular file returns False. A complete answer explains why the near-miss fails, names the evidence that distinguishes it from the corrected case and transfers the rule without relying on the original variable names.

Diagnostic route

  • Model check: draw or list the exact values, objects, paths, characters or repository states before the operation.
  • Boundary check: construct the smallest safe input that reveals assuming every reparse-aware predicate identifies any path.
  • Evidence check: distinguish a displayed result from ownership, caching, consumption, font behaviour or object type.
  • Repair check: Use a temporary file beside the directory fixture.
  • Transfer check: repeat the rule in a second context and name what remains unchanged.

A parent does not need to memorise Python pathlib.Path.is_junction to support “A regular file is not a junction”. Useful prompts are: “What did you expect?”, “Which state changed first?”, “What evidence tests A normal file does not satisfy the junction predicate.?”, and “Can you make a smaller example of assuming every reparse-aware predicate identifies any path?” These questions keep ownership with the learner while making the reasoning visible.

Practice with an explained answer

Task. Compare is_file and is_junction. Write the prediction before running anything. Include one ordinary case and one boundary case, then explain the difference in two causal sentences.

Answer route. The file can be True for is_file while remaining False for is_junction. The final output alone earns only partial credit. A strong answer connects it to “A normal file does not satisfy the junction predicate.”, shows the relevant intermediate evidence and states why assuming every reparse-aware predicate identifies any path would lead to a different conclusion.

Decision and transfer

Combine predicates only when the decision table requires them. Prefer the choice whose semantics and failure modes are easiest to explain for the actual job. Shorter syntax is useful only when it preserves that clarity.

Mastery of “A regular file is not a junction” means the learner can predict the ordinary case, recognise assuming every reparse-aware predicate identifies any path, diagnose the earliest mistaken assumption, recover with “Use a temporary file beside the directory fixture.” and defend this decision: Combine predicates only when the decision table requires them. Once that causal chain is stable, continue to the next chapter rather than adding repetitions of the same surface exercise.

Previous section · Contents · Next section

CHAPTER 6 OF 20 · Read the contract

6. A missing path is not positive evidence

Back to contents

A pathname that does not identify a junction must not be treated as a positive junction match. That is the invariant to preserve when names, data or surrounding project details change.

One Boolean cannot establish existence and type simultaneously. The useful question is not “Which line should I copy?” but “Which state, value or rendering decision does this operation control?” Answering that question prevents a correct-looking result from hiding a wrong mental model.

The most revealing near-miss is reading False as proof that an ordinary directory exists. A learner should predict the result first, run the smallest safe case, label the observation and explain the earliest point where the prediction diverges. This turns an error into evidence rather than a verdict on ability.

Core worked example

from pathlib import Path
print(Path('definitely-missing').is_junction())

Explained result. The ordinary missing-path fixture returns False on supported current runtimes. The explanation should identify the input, the governing rule, the observable outcome and one boundary that would change the conclusion. If any of those four parts is missing, reduce the example and trace it again.

Read the trace, not just the last line

Trace missing lookup and negative classification separately from directory existence. Write the trace as a sequence of labelled states. For Python pathlib.Path.is_junction, inspect resolved pathnames, stat identities, exception types and before-and-after directory listings; a single final value can hide the mechanism that produced it.

For “A missing path is not positive evidence”, separate contract from coincidence. The contract is “A pathname that does not identify a junction must not be treated as a positive junction match.” and comes from the primary specification or manual. Coincidence is what happened on one machine, font, filesystem or repository. Record both, then use “Pair the classifier with an explicit existence or error policy where absence matters.” to decide whether another observation challenges the model or merely reflects the environment.

Four purposeful transfer cases

Case 1: homework export guard. Model “A missing path is not positive evidence” with an input document, two path spellings and a proposed output. Before touching a tool, state which part of the case corresponds to the input, why “A pathname that does not identify a junction must not be treated as a positive junction match.” should remain invariant and what observation would expose reading False as proof that an ordinary directory exists.

Reasoned route. Begin with “A pathname that does not identify a junction must not be treated as a positive junction match.” Apply this procedure: Pair the classifier with an explicit existence or error policy where absence matters. For the homework export guard, introduce one controlled variation that exposes reading False as proof that an ordinary directory exists. The ordinary missing-path fixture returns False on supported current runtimes. A complete answer explains why the near-miss fails, names the evidence that distinguishes it from the corrected case and transfers the rule without relying on the original variable names.

Case 2: photo-library alias check. Contrast “A missing path is not positive evidence” with original files, hard-link aliases and independent copies. Before touching a tool, state which part of the case corresponds to the input, why “A pathname that does not identify a junction must not be treated as a positive junction match.” should remain invariant and what observation would expose reading False as proof that an ordinary directory exists.

Reasoned route. Begin with “A pathname that does not identify a junction must not be treated as a positive junction match.” Apply this procedure: Pair the classifier with an explicit existence or error policy where absence matters. For the photo-library alias check, introduce one controlled variation that exposes reading False as proof that an ordinary directory exists. The ordinary missing-path fixture returns False on supported current runtimes. A complete answer explains why the near-miss fails, names the evidence that distinguishes it from the corrected case and transfers the rule without relying on the original variable names.

Case 3: science-data archive. Stress-test “A missing path is not positive evidence” with raw readings, a symlinked working folder and a missing target. Before touching a tool, state which part of the case corresponds to the input, why “A pathname that does not identify a junction must not be treated as a positive junction match.” should remain invariant and what observation would expose reading False as proof that an ordinary directory exists.

Reasoned route. Begin with “A pathname that does not identify a junction must not be treated as a positive junction match.” Apply this procedure: Pair the classifier with an explicit existence or error policy where absence matters. For the science-data archive, introduce one controlled variation that exposes reading False as proof that an ordinary directory exists. The ordinary missing-path fixture returns False on supported current runtimes. A complete answer explains why the near-miss fails, names the evidence that distinguishes it from the corrected case and transfers the rule without relying on the original variable names.

Case 4: backup verification task. Explain “A missing path is not positive evidence” with source directories, mounted destinations and privacy-safe diagnostics. Before touching a tool, state which part of the case corresponds to the input, why “A pathname that does not identify a junction must not be treated as a positive junction match.” should remain invariant and what observation would expose reading False as proof that an ordinary directory exists.

Reasoned route. Begin with “A pathname that does not identify a junction must not be treated as a positive junction match.” Apply this procedure: Pair the classifier with an explicit existence or error policy where absence matters. For the backup verification task, introduce one controlled variation that exposes reading False as proof that an ordinary directory exists. The ordinary missing-path fixture returns False on supported current runtimes. A complete answer explains why the near-miss fails, names the evidence that distinguishes it from the corrected case and transfers the rule without relying on the original variable names.

Diagnostic route

  • Model check: draw or list the exact values, objects, paths, characters or repository states before the operation.
  • Boundary check: construct the smallest safe input that reveals reading False as proof that an ordinary directory exists.
  • Evidence check: distinguish a displayed result from ownership, caching, consumption, font behaviour or object type.
  • Repair check: Pair the classifier with an explicit existence or error policy where absence matters.
  • Transfer check: repeat the rule in a second context and name what remains unchanged.

A parent does not need to memorise Python pathlib.Path.is_junction to support “A missing path is not positive evidence”. Useful prompts are: “What did you expect?”, “Which state changed first?”, “What evidence tests A pathname that does not identify a junction must not be treated as a positive junction match.?”, and “Can you make a smaller example of reading False as proof that an ordinary directory exists?” These questions keep ownership with the learner while making the reasoning visible.

Practice with an explained answer

Task. Design a three-state report. Write the prediction before running anything. Include one ordinary case and one boundary case, then explain the difference in two causal sentences.

Answer route. Record junction, non-junction existing path and missing path separately. The final output alone earns only partial credit. A strong answer connects it to “A pathname that does not identify a junction must not be treated as a positive junction match.”, shows the relevant intermediate evidence and states why reading False as proof that an ordinary directory exists would lead to a different conclusion.

Decision and transfer

Preserve absence as its own application state. Prefer the choice whose semantics and failure modes are easiest to explain for the actual job. Shorter syntax is useful only when it preserves that clarity.

Mastery of “A missing path is not positive evidence” means the learner can predict the ordinary case, recognise reading False as proof that an ordinary directory exists, diagnose the earliest mistaken assumption, recover with “Pair the classifier with an explicit existence or error policy where absence matters.” and defend this decision: Preserve absence as its own application state. Once that causal chain is stable, continue to the next chapter rather than adding repetitions of the same surface exercise.

Previous section · Contents · Next section

Path.is_junction and Path.is_symlink ask different filesystem questions. That is the invariant to preserve when names, data or surrounding project details change.

Windows exposes several kinds of reparse-based redirection with different semantics. The useful question is not “Which line should I copy?” but “Which state, value or rendering decision does this operation control?” Answering that question prevents a correct-looking result from hiding a wrong mental model.

The most revealing near-miss is using is_symlink as a universal redirect detector. A learner should predict the result first, run the smallest safe case, label the observation and explain the earliest point where the prediction diverges. This turns an error into evidence rather than a verdict on ability.

Core worked example

print(path.is_junction(), path.is_symlink())

Explained result. A fixture can be classified by the predicate matching its actual mechanism. The explanation should identify the input, the governing rule, the observable outcome and one boundary that would change the conclusion. If any of those four parts is missing, reduce the example and trace it again.

Read the trace, not just the last line

Trace both predicates for each fixture. Write the trace as a sequence of labelled states. For Python pathlib.Path.is_junction, inspect resolved pathnames, stat identities, exception types and before-and-after directory listings; a single final value can hide the mechanism that produced it.

For “A junction and a symbolic link are not interchangeable”, separate contract from coincidence. The contract is “Path.is_junction and Path.is_symlink ask different filesystem questions.” and comes from the primary specification or manual. Coincidence is what happened on one machine, font, filesystem or repository. Record both, then use “Create separate documented fixtures rather than renaming one mechanism.” to decide whether another observation challenges the model or merely reflects the environment.

Four purposeful transfer cases

Case 1: homework export guard. Model “A junction and a symbolic link are not interchangeable” with an input document, two path spellings and a proposed output. Before touching a tool, state which part of the case corresponds to the input, why “Path.is_junction and Path.is_symlink ask different filesystem questions.” should remain invariant and what observation would expose using is_symlink as a universal redirect detector.

Reasoned route. Begin with “Path.is_junction and Path.is_symlink ask different filesystem questions.” Apply this procedure: Create separate documented fixtures rather than renaming one mechanism. For the homework export guard, introduce one controlled variation that exposes using is_symlink as a universal redirect detector. A fixture can be classified by the predicate matching its actual mechanism. A complete answer explains why the near-miss fails, names the evidence that distinguishes it from the corrected case and transfers the rule without relying on the original variable names.

Case 2: photo-library alias check. Contrast “A junction and a symbolic link are not interchangeable” with original files, hard-link aliases and independent copies. Before touching a tool, state which part of the case corresponds to the input, why “Path.is_junction and Path.is_symlink ask different filesystem questions.” should remain invariant and what observation would expose using is_symlink as a universal redirect detector.

Reasoned route. Begin with “Path.is_junction and Path.is_symlink ask different filesystem questions.” Apply this procedure: Create separate documented fixtures rather than renaming one mechanism. For the photo-library alias check, introduce one controlled variation that exposes using is_symlink as a universal redirect detector. A fixture can be classified by the predicate matching its actual mechanism. A complete answer explains why the near-miss fails, names the evidence that distinguishes it from the corrected case and transfers the rule without relying on the original variable names.

Case 3: science-data archive. Stress-test “A junction and a symbolic link are not interchangeable” with raw readings, a symlinked working folder and a missing target. Before touching a tool, state which part of the case corresponds to the input, why “Path.is_junction and Path.is_symlink ask different filesystem questions.” should remain invariant and what observation would expose using is_symlink as a universal redirect detector.

Reasoned route. Begin with “Path.is_junction and Path.is_symlink ask different filesystem questions.” Apply this procedure: Create separate documented fixtures rather than renaming one mechanism. For the science-data archive, introduce one controlled variation that exposes using is_symlink as a universal redirect detector. A fixture can be classified by the predicate matching its actual mechanism. A complete answer explains why the near-miss fails, names the evidence that distinguishes it from the corrected case and transfers the rule without relying on the original variable names.

Case 4: backup verification task. Explain “A junction and a symbolic link are not interchangeable” with source directories, mounted destinations and privacy-safe diagnostics. Before touching a tool, state which part of the case corresponds to the input, why “Path.is_junction and Path.is_symlink ask different filesystem questions.” should remain invariant and what observation would expose using is_symlink as a universal redirect detector.

Reasoned route. Begin with “Path.is_junction and Path.is_symlink ask different filesystem questions.” Apply this procedure: Create separate documented fixtures rather than renaming one mechanism. For the backup verification task, introduce one controlled variation that exposes using is_symlink as a universal redirect detector. A fixture can be classified by the predicate matching its actual mechanism. A complete answer explains why the near-miss fails, names the evidence that distinguishes it from the corrected case and transfers the rule without relying on the original variable names.

Diagnostic route

  • Model check: draw or list the exact values, objects, paths, characters or repository states before the operation.
  • Boundary check: construct the smallest safe input that reveals using is_symlink as a universal redirect detector.
  • Evidence check: distinguish a displayed result from ownership, caching, consumption, font behaviour or object type.
  • Repair check: Create separate documented fixtures rather than renaming one mechanism.
  • Transfer check: repeat the rule in a second context and name what remains unchanged.

A parent does not need to memorise Python pathlib.Path.is_junction to support “A junction and a symbolic link are not interchangeable”. Useful prompts are: “What did you expect?”, “Which state changed first?”, “What evidence tests Path.is_junction and Path.is_symlink ask different filesystem questions.?”, and “Can you make a smaller example of using is_symlink as a universal redirect detector?” These questions keep ownership with the learner while making the reasoning visible.

Practice with an explained answer

Task. Build a two-column classification table. Write the prediction before running anything. Include one ordinary case and one boundary case, then explain the difference in two causal sentences.

Answer route. Do not infer one predicate from the other without observed evidence. The final output alone earns only partial credit. A strong answer connects it to “Path.is_junction and Path.is_symlink ask different filesystem questions.”, shows the relevant intermediate evidence and states why using is_symlink as a universal redirect detector would lead to a different conclusion.

Decision and transfer

Keep junction and symlink policy branches explicit. Prefer the choice whose semantics and failure modes are easiest to explain for the actual job. Shorter syntax is useful only when it preserves that clarity.

Mastery of “A junction and a symbolic link are not interchangeable” means the learner can predict the ordinary case, recognise using is_symlink as a universal redirect detector, diagnose the earliest mistaken assumption, recover with “Create separate documented fixtures rather than renaming one mechanism.” and defend this decision: Keep junction and symlink policy branches explicit. Once that causal chain is stable, continue to the next chapter rather than adding repetitions of the same surface exercise.

Previous section · Contents · Next section

CHAPTER 8 OF 20 · Read the contract

8. A junction and a mount point answer different questions

Back to contents

Path.is_mount checks mount-point semantics while Path.is_junction checks the Windows junction category. That is the invariant to preserve when names, data or surrounding project details change.

Mount topology and junction identity are neighbouring, not identical, models. The useful question is not “Which line should I copy?” but “Which state, value or rendering decision does this operation control?” Answering that question prevents a correct-looking result from hiding a wrong mental model.

The most revealing near-miss is using a True result from either method as a synonym for redirected directory. A learner should predict the result first, run the smallest safe case, label the observation and explain the earliest point where the prediction diverges. This turns an error into evidence rather than a verdict on ability.

Core worked example

print(path.is_mount(), path.is_junction())

Explained result. The two answers can differ because the predicates have different contracts. The explanation should identify the input, the governing rule, the observable outcome and one boundary that would change the conclusion. If any of those four parts is missing, reduce the example and trace it again.

Read the trace, not just the last line

Trace which predicate governs each row. Write the trace as a sequence of labelled states. For Python pathlib.Path.is_junction, inspect resolved pathnames, stat identities, exception types and before-and-after directory listings; a single final value can hide the mechanism that produced it.

For “A junction and a mount point answer different questions”, separate contract from coincidence. The contract is “Path.is_mount checks mount-point semantics while Path.is_junction checks the Windows junction category.” and comes from the primary specification or manual. Coincidence is what happened on one machine, font, filesystem or repository. Record both, then use “Test a known drive root, ordinary directory and controlled junction.” to decide whether another observation challenges the model or merely reflects the environment.

Four purposeful transfer cases

Case 1: homework export guard. Model “A junction and a mount point answer different questions” with an input document, two path spellings and a proposed output. Before touching a tool, state which part of the case corresponds to the input, why “Path.is_mount checks mount-point semantics while Path.is_junction checks the Windows junction category.” should remain invariant and what observation would expose using a True result from either method as a synonym for redirected directory.

Reasoned route. Begin with “Path.is_mount checks mount-point semantics while Path.is_junction checks the Windows junction category.” Apply this procedure: Test a known drive root, ordinary directory and controlled junction. For the homework export guard, introduce one controlled variation that exposes using a True result from either method as a synonym for redirected directory. The two answers can differ because the predicates have different contracts. A complete answer explains why the near-miss fails, names the evidence that distinguishes it from the corrected case and transfers the rule without relying on the original variable names.

Case 2: photo-library alias check. Contrast “A junction and a mount point answer different questions” with original files, hard-link aliases and independent copies. Before touching a tool, state which part of the case corresponds to the input, why “Path.is_mount checks mount-point semantics while Path.is_junction checks the Windows junction category.” should remain invariant and what observation would expose using a True result from either method as a synonym for redirected directory.

Reasoned route. Begin with “Path.is_mount checks mount-point semantics while Path.is_junction checks the Windows junction category.” Apply this procedure: Test a known drive root, ordinary directory and controlled junction. For the photo-library alias check, introduce one controlled variation that exposes using a True result from either method as a synonym for redirected directory. The two answers can differ because the predicates have different contracts. A complete answer explains why the near-miss fails, names the evidence that distinguishes it from the corrected case and transfers the rule without relying on the original variable names.

Case 3: science-data archive. Stress-test “A junction and a mount point answer different questions” with raw readings, a symlinked working folder and a missing target. Before touching a tool, state which part of the case corresponds to the input, why “Path.is_mount checks mount-point semantics while Path.is_junction checks the Windows junction category.” should remain invariant and what observation would expose using a True result from either method as a synonym for redirected directory.

Reasoned route. Begin with “Path.is_mount checks mount-point semantics while Path.is_junction checks the Windows junction category.” Apply this procedure: Test a known drive root, ordinary directory and controlled junction. For the science-data archive, introduce one controlled variation that exposes using a True result from either method as a synonym for redirected directory. The two answers can differ because the predicates have different contracts. A complete answer explains why the near-miss fails, names the evidence that distinguishes it from the corrected case and transfers the rule without relying on the original variable names.

Case 4: backup verification task. Explain “A junction and a mount point answer different questions” with source directories, mounted destinations and privacy-safe diagnostics. Before touching a tool, state which part of the case corresponds to the input, why “Path.is_mount checks mount-point semantics while Path.is_junction checks the Windows junction category.” should remain invariant and what observation would expose using a True result from either method as a synonym for redirected directory.

Reasoned route. Begin with “Path.is_mount checks mount-point semantics while Path.is_junction checks the Windows junction category.” Apply this procedure: Test a known drive root, ordinary directory and controlled junction. For the backup verification task, introduce one controlled variation that exposes using a True result from either method as a synonym for redirected directory. The two answers can differ because the predicates have different contracts. A complete answer explains why the near-miss fails, names the evidence that distinguishes it from the corrected case and transfers the rule without relying on the original variable names.

Diagnostic route

  • Model check: draw or list the exact values, objects, paths, characters or repository states before the operation.
  • Boundary check: construct the smallest safe input that reveals using a True result from either method as a synonym for redirected directory.
  • Evidence check: distinguish a displayed result from ownership, caching, consumption, font behaviour or object type.
  • Repair check: Test a known drive root, ordinary directory and controlled junction.
  • Transfer check: repeat the rule in a second context and name what remains unchanged.

A parent does not need to memorise Python pathlib.Path.is_junction to support “A junction and a mount point answer different questions”. Useful prompts are: “What did you expect?”, “Which state changed first?”, “What evidence tests Path.is_mount checks mount-point semantics while Path.is_junction checks the Windows junction category.?”, and “Can you make a smaller example of using a True result from either method as a synonym for redirected directory?” These questions keep ownership with the learner while making the reasoning visible.

Practice with an explained answer

Task. Explain why a drive root need not be a junction. Write the prediction before running anything. Include one ordinary case and one boundary case, then explain the difference in two causal sentences.

Answer route. Windows mount-point rules include roots and shares beyond junctions. The final output alone earns only partial credit. A strong answer connects it to “Path.is_mount checks mount-point semantics while Path.is_junction checks the Windows junction category.”, shows the relevant intermediate evidence and states why using a True result from either method as a synonym for redirected directory would lead to a different conclusion.

Decision and transfer

Use is_mount for mount policy and is_junction for junction policy. Prefer the choice whose semantics and failure modes are easiest to explain for the actual job. Shorter syntax is useful only when it preserves that clarity.

Mastery of “A junction and a mount point answer different questions” means the learner can predict the ordinary case, recognise using a True result from either method as a synonym for redirected directory, diagnose the earliest mistaken assumption, recover with “Test a known drive root, ordinary directory and controlled junction.” and defend this decision: Use is_mount for mount policy and is_junction for junction policy. Once that causal chain is stable, continue to the next chapter rather than adding repetitions of the same surface exercise.

Previous section · Contents · Next section

CHAPTER 9 OF 20 · Test the boundary

9. The Path object does not classify itself lexically

Back to contents

The method performs a concrete filesystem query; pathname spelling alone is insufficient. That is the invariant to preserve when names, data or surrounding project details change.

Junction identity is metadata, not filename syntax. The useful question is not “Which line should I copy?” but “Which state, value or rendering decision does this operation control?” Answering that question prevents a correct-looking result from hiding a wrong mental model.

The most revealing near-miss is searching the string for a junction-looking pattern. A learner should predict the result first, run the smallest safe case, label the observation and explain the earliest point where the prediction diverges. This turns an error into evidence rather than a verdict on ability.

Core worked example

p=Path(r'C:\work\..\work\shared')
print(p.is_junction())

Explained result. The lookup classifies the reached path object rather than counting separators or dots. The explanation should identify the input, the governing rule, the observable outcome and one boundary that would change the conclusion. If any of those four parts is missing, reduce the example and trace it again.

Read the trace, not just the last line

Trace lexical path handling and concrete lookup. Write the trace as a sequence of labelled states. For Python pathlib.Path.is_junction, inspect resolved pathnames, stat identities, exception types and before-and-after directory listings; a single final value can hide the mechanism that produced it.

For “The Path object does not classify itself lexically”, separate contract from coincidence. The contract is “The method performs a concrete filesystem query; pathname spelling alone is insufficient.” and comes from the primary specification or manual. Coincidence is what happened on one machine, font, filesystem or repository. Record both, then use “Compare two lexical spellings that reach the same controlled entry.” to decide whether another observation challenges the model or merely reflects the environment.

Four purposeful transfer cases

Case 1: homework export guard. Model “The Path object does not classify itself lexically” with an input document, two path spellings and a proposed output. Before touching a tool, state which part of the case corresponds to the input, why “The method performs a concrete filesystem query; pathname spelling alone is insufficient.” should remain invariant and what observation would expose searching the string for a junction-looking pattern.

Reasoned route. Begin with “The method performs a concrete filesystem query; pathname spelling alone is insufficient.” Apply this procedure: Compare two lexical spellings that reach the same controlled entry. For the homework export guard, introduce one controlled variation that exposes searching the string for a junction-looking pattern. The lookup classifies the reached path object rather than counting separators or dots. A complete answer explains why the near-miss fails, names the evidence that distinguishes it from the corrected case and transfers the rule without relying on the original variable names.

Case 2: photo-library alias check. Contrast “The Path object does not classify itself lexically” with original files, hard-link aliases and independent copies. Before touching a tool, state which part of the case corresponds to the input, why “The method performs a concrete filesystem query; pathname spelling alone is insufficient.” should remain invariant and what observation would expose searching the string for a junction-looking pattern.

Reasoned route. Begin with “The method performs a concrete filesystem query; pathname spelling alone is insufficient.” Apply this procedure: Compare two lexical spellings that reach the same controlled entry. For the photo-library alias check, introduce one controlled variation that exposes searching the string for a junction-looking pattern. The lookup classifies the reached path object rather than counting separators or dots. A complete answer explains why the near-miss fails, names the evidence that distinguishes it from the corrected case and transfers the rule without relying on the original variable names.

Case 3: science-data archive. Stress-test “The Path object does not classify itself lexically” with raw readings, a symlinked working folder and a missing target. Before touching a tool, state which part of the case corresponds to the input, why “The method performs a concrete filesystem query; pathname spelling alone is insufficient.” should remain invariant and what observation would expose searching the string for a junction-looking pattern.

Reasoned route. Begin with “The method performs a concrete filesystem query; pathname spelling alone is insufficient.” Apply this procedure: Compare two lexical spellings that reach the same controlled entry. For the science-data archive, introduce one controlled variation that exposes searching the string for a junction-looking pattern. The lookup classifies the reached path object rather than counting separators or dots. A complete answer explains why the near-miss fails, names the evidence that distinguishes it from the corrected case and transfers the rule without relying on the original variable names.

Case 4: backup verification task. Explain “The Path object does not classify itself lexically” with source directories, mounted destinations and privacy-safe diagnostics. Before touching a tool, state which part of the case corresponds to the input, why “The method performs a concrete filesystem query; pathname spelling alone is insufficient.” should remain invariant and what observation would expose searching the string for a junction-looking pattern.

Reasoned route. Begin with “The method performs a concrete filesystem query; pathname spelling alone is insufficient.” Apply this procedure: Compare two lexical spellings that reach the same controlled entry. For the backup verification task, introduce one controlled variation that exposes searching the string for a junction-looking pattern. The lookup classifies the reached path object rather than counting separators or dots. A complete answer explains why the near-miss fails, names the evidence that distinguishes it from the corrected case and transfers the rule without relying on the original variable names.

Diagnostic route

  • Model check: draw or list the exact values, objects, paths, characters or repository states before the operation.
  • Boundary check: construct the smallest safe input that reveals searching the string for a junction-looking pattern.
  • Evidence check: distinguish a displayed result from ownership, caching, consumption, font behaviour or object type.
  • Repair check: Compare two lexical spellings that reach the same controlled entry.
  • Transfer check: repeat the rule in a second context and name what remains unchanged.

A parent does not need to memorise Python pathlib.Path.is_junction to support “The Path object does not classify itself lexically”. Useful prompts are: “What did you expect?”, “Which state changed first?”, “What evidence tests The method performs a concrete filesystem query; pathname spelling alone is insufficient.?”, and “Can you make a smaller example of searching the string for a junction-looking pattern?” These questions keep ownership with the learner while making the reasoning visible.

Practice with an explained answer

Task. Predict from names alone. Write the prediction before running anything. Include one ordinary case and one boundary case, then explain the difference in two causal sentences.

Answer route. The correct prediction remains conditional until the filesystem is queried. The final output alone earns only partial credit. A strong answer connects it to “The method performs a concrete filesystem query; pathname spelling alone is insufficient.”, shows the relevant intermediate evidence and states why searching the string for a junction-looking pattern would lead to a different conclusion.

Decision and transfer

Avoid regex-based filesystem classification. Prefer the choice whose semantics and failure modes are easiest to explain for the actual job. Shorter syntax is useful only when it preserves that clarity.

Mastery of “The Path object does not classify itself lexically” means the learner can predict the ordinary case, recognise searching the string for a junction-looking pattern, diagnose the earliest mistaken assumption, recover with “Compare two lexical spellings that reach the same controlled entry.” and defend this decision: Avoid regex-based filesystem classification. Once that causal chain is stable, continue to the next chapter rather than adding repetitions of the same surface exercise.

Previous section · Contents · Next section

CHAPTER 10 OF 20 · Test the boundary

10. Relative paths depend on the current working directory

Back to contents

A relative Path is resolved for the query from the process current directory. That is the invariant to preserve when names, data or surrounding project details change.

Concrete classification depends on which entry the pathname reaches. The useful question is not “Which line should I copy?” but “Which state, value or rendering decision does this operation control?” Answering that question prevents a correct-looking result from hiding a wrong mental model.

The most revealing near-miss is treating a relative path as globally stable. A learner should predict the result first, run the smallest safe case, label the observation and explain the earliest point where the prediction diverges. This turns an error into evidence rather than a verdict on ability.

Core worked example

from pathlib import Path
print(Path('shared').is_junction())

Explained result. Changing the working directory can make the same text reach a different object. The explanation should identify the input, the governing rule, the observable outcome and one boundary that would change the conclusion. If any of those four parts is missing, reduce the example and trace it again.

Read the trace, not just the last line

Trace cwd, relative pathname and selected directory entry. Write the trace as a sequence of labelled states. For Python pathlib.Path.is_junction, inspect resolved pathnames, stat identities, exception types and before-and-after directory listings; a single final value can hide the mechanism that produced it.

For “Relative paths depend on the current working directory”, separate contract from coincidence. The contract is “A relative Path is resolved for the query from the process current directory.” and comes from the primary specification or manual. Coincidence is what happened on one machine, font, filesystem or repository. Record both, then use “Use two temporary parent folders with different shared entries.” to decide whether another observation challenges the model or merely reflects the environment.

Four purposeful transfer cases

Case 1: homework export guard. Model “Relative paths depend on the current working directory” with an input document, two path spellings and a proposed output. Before touching a tool, state which part of the case corresponds to the input, why “A relative Path is resolved for the query from the process current directory.” should remain invariant and what observation would expose treating a relative path as globally stable.

Reasoned route. Begin with “A relative Path is resolved for the query from the process current directory.” Apply this procedure: Use two temporary parent folders with different shared entries. For the homework export guard, introduce one controlled variation that exposes treating a relative path as globally stable. Changing the working directory can make the same text reach a different object. A complete answer explains why the near-miss fails, names the evidence that distinguishes it from the corrected case and transfers the rule without relying on the original variable names.

Case 2: photo-library alias check. Contrast “Relative paths depend on the current working directory” with original files, hard-link aliases and independent copies. Before touching a tool, state which part of the case corresponds to the input, why “A relative Path is resolved for the query from the process current directory.” should remain invariant and what observation would expose treating a relative path as globally stable.

Reasoned route. Begin with “A relative Path is resolved for the query from the process current directory.” Apply this procedure: Use two temporary parent folders with different shared entries. For the photo-library alias check, introduce one controlled variation that exposes treating a relative path as globally stable. Changing the working directory can make the same text reach a different object. A complete answer explains why the near-miss fails, names the evidence that distinguishes it from the corrected case and transfers the rule without relying on the original variable names.

Case 3: science-data archive. Stress-test “Relative paths depend on the current working directory” with raw readings, a symlinked working folder and a missing target. Before touching a tool, state which part of the case corresponds to the input, why “A relative Path is resolved for the query from the process current directory.” should remain invariant and what observation would expose treating a relative path as globally stable.

Reasoned route. Begin with “A relative Path is resolved for the query from the process current directory.” Apply this procedure: Use two temporary parent folders with different shared entries. For the science-data archive, introduce one controlled variation that exposes treating a relative path as globally stable. Changing the working directory can make the same text reach a different object. A complete answer explains why the near-miss fails, names the evidence that distinguishes it from the corrected case and transfers the rule without relying on the original variable names.

Case 4: backup verification task. Explain “Relative paths depend on the current working directory” with source directories, mounted destinations and privacy-safe diagnostics. Before touching a tool, state which part of the case corresponds to the input, why “A relative Path is resolved for the query from the process current directory.” should remain invariant and what observation would expose treating a relative path as globally stable.

Reasoned route. Begin with “A relative Path is resolved for the query from the process current directory.” Apply this procedure: Use two temporary parent folders with different shared entries. For the backup verification task, introduce one controlled variation that exposes treating a relative path as globally stable. Changing the working directory can make the same text reach a different object. A complete answer explains why the near-miss fails, names the evidence that distinguishes it from the corrected case and transfers the rule without relying on the original variable names.

Diagnostic route

  • Model check: draw or list the exact values, objects, paths, characters or repository states before the operation.
  • Boundary check: construct the smallest safe input that reveals treating a relative path as globally stable.
  • Evidence check: distinguish a displayed result from ownership, caching, consumption, font behaviour or object type.
  • Repair check: Use two temporary parent folders with different shared entries.
  • Transfer check: repeat the rule in a second context and name what remains unchanged.

A parent does not need to memorise Python pathlib.Path.is_junction to support “Relative paths depend on the current working directory”. Useful prompts are: “What did you expect?”, “Which state changed first?”, “What evidence tests A relative Path is resolved for the query from the process current directory.?”, and “Can you make a smaller example of treating a relative path as globally stable?” These questions keep ownership with the learner while making the reasoning visible.

Practice with an explained answer

Task. Run after an intentional cwd change. Write the prediction before running anything. Include one ordinary case and one boundary case, then explain the difference in two causal sentences.

Answer route. The classification follows the new resolution context. The final output alone earns only partial credit. A strong answer connects it to “A relative Path is resolved for the query from the process current directory.”, shows the relevant intermediate evidence and states why treating a relative path as globally stable would lead to a different conclusion.

Decision and transfer

Prefer explicit roots in maintenance tools. Prefer the choice whose semantics and failure modes are easiest to explain for the actual job. Shorter syntax is useful only when it preserves that clarity.

Mastery of “Relative paths depend on the current working directory” means the learner can predict the ordinary case, recognise treating a relative path as globally stable, diagnose the earliest mistaken assumption, recover with “Use two temporary parent folders with different shared entries.” and defend this decision: Prefer explicit roots in maintenance tools. Once that causal chain is stable, continue to the next chapter rather than adding repetitions of the same surface exercise.

Previous section · Contents · Next section

CHAPTER 11 OF 20 · Test the boundary

11. PurePath cannot inspect junctions

Back to contents

PurePath models path syntax and does not offer concrete filesystem classification. That is the invariant to preserve when names, data or surrounding project details change.

Pure and concrete paths deliberately separate lexical work from I/O. The useful question is not “Which line should I copy?” but “Which state, value or rendering decision does this operation control?” Answering that question prevents a correct-looking result from hiding a wrong mental model.

The most revealing near-miss is expecting a PurePath to query a live disk. A learner should predict the result first, run the smallest safe case, label the observation and explain the earliest point where the prediction diverges. This turns an error into evidence rather than a verdict on ability.

Core worked example

from pathlib import PureWindowsPath
p=PureWindowsPath(r'C:\work\shared')
print(type(p).__name__)

Explained result. The pure path can model Windows spelling without proving the entry is a junction. The explanation should identify the input, the governing rule, the observable outcome and one boundary that would change the conclusion. If any of those four parts is missing, reduce the example and trace it again.

Read the trace, not just the last line

Trace which object can perform I/O. Write the trace as a sequence of labelled states. For Python pathlib.Path.is_junction, inspect resolved pathnames, stat identities, exception types and before-and-after directory listings; a single final value can hide the mechanism that produced it.

For “PurePath cannot inspect junctions”, separate contract from coincidence. The contract is “PurePath models path syntax and does not offer concrete filesystem classification.” and comes from the primary specification or manual. Coincidence is what happened on one machine, font, filesystem or repository. Record both, then use “Use PureWindowsPath for syntax examples and Path on the target Windows system for observation.” to decide whether another observation challenges the model or merely reflects the environment.

Four purposeful transfer cases

Case 1: homework export guard. Model “PurePath cannot inspect junctions” with an input document, two path spellings and a proposed output. Before touching a tool, state which part of the case corresponds to the input, why “PurePath models path syntax and does not offer concrete filesystem classification.” should remain invariant and what observation would expose expecting a PurePath to query a live disk.

Reasoned route. Begin with “PurePath models path syntax and does not offer concrete filesystem classification.” Apply this procedure: Use PureWindowsPath for syntax examples and Path on the target Windows system for observation. For the homework export guard, introduce one controlled variation that exposes expecting a PurePath to query a live disk. The pure path can model Windows spelling without proving the entry is a junction. A complete answer explains why the near-miss fails, names the evidence that distinguishes it from the corrected case and transfers the rule without relying on the original variable names.

Case 2: photo-library alias check. Contrast “PurePath cannot inspect junctions” with original files, hard-link aliases and independent copies. Before touching a tool, state which part of the case corresponds to the input, why “PurePath models path syntax and does not offer concrete filesystem classification.” should remain invariant and what observation would expose expecting a PurePath to query a live disk.

Reasoned route. Begin with “PurePath models path syntax and does not offer concrete filesystem classification.” Apply this procedure: Use PureWindowsPath for syntax examples and Path on the target Windows system for observation. For the photo-library alias check, introduce one controlled variation that exposes expecting a PurePath to query a live disk. The pure path can model Windows spelling without proving the entry is a junction. A complete answer explains why the near-miss fails, names the evidence that distinguishes it from the corrected case and transfers the rule without relying on the original variable names.

Case 3: science-data archive. Stress-test “PurePath cannot inspect junctions” with raw readings, a symlinked working folder and a missing target. Before touching a tool, state which part of the case corresponds to the input, why “PurePath models path syntax and does not offer concrete filesystem classification.” should remain invariant and what observation would expose expecting a PurePath to query a live disk.

Reasoned route. Begin with “PurePath models path syntax and does not offer concrete filesystem classification.” Apply this procedure: Use PureWindowsPath for syntax examples and Path on the target Windows system for observation. For the science-data archive, introduce one controlled variation that exposes expecting a PurePath to query a live disk. The pure path can model Windows spelling without proving the entry is a junction. A complete answer explains why the near-miss fails, names the evidence that distinguishes it from the corrected case and transfers the rule without relying on the original variable names.

Case 4: backup verification task. Explain “PurePath cannot inspect junctions” with source directories, mounted destinations and privacy-safe diagnostics. Before touching a tool, state which part of the case corresponds to the input, why “PurePath models path syntax and does not offer concrete filesystem classification.” should remain invariant and what observation would expose expecting a PurePath to query a live disk.

Reasoned route. Begin with “PurePath models path syntax and does not offer concrete filesystem classification.” Apply this procedure: Use PureWindowsPath for syntax examples and Path on the target Windows system for observation. For the backup verification task, introduce one controlled variation that exposes expecting a PurePath to query a live disk. The pure path can model Windows spelling without proving the entry is a junction. A complete answer explains why the near-miss fails, names the evidence that distinguishes it from the corrected case and transfers the rule without relying on the original variable names.

Diagnostic route

  • Model check: draw or list the exact values, objects, paths, characters or repository states before the operation.
  • Boundary check: construct the smallest safe input that reveals expecting a PurePath to query a live disk.
  • Evidence check: distinguish a displayed result from ownership, caching, consumption, font behaviour or object type.
  • Repair check: Use PureWindowsPath for syntax examples and Path on the target Windows system for observation.
  • Transfer check: repeat the rule in a second context and name what remains unchanged.

A parent does not need to memorise Python pathlib.Path.is_junction to support “PurePath cannot inspect junctions”. Useful prompts are: “What did you expect?”, “Which state changed first?”, “What evidence tests PurePath models path syntax and does not offer concrete filesystem classification.?”, and “Can you make a smaller example of expecting a PurePath to query a live disk?” These questions keep ownership with the learner while making the reasoning visible.

Practice with an explained answer

Task. Ask PureWindowsPath for is_junction. Write the prediction before running anything. Include one ordinary case and one boundary case, then explain the difference in two causal sentences.

Answer route. The concrete-only operation is not the job of PurePath. The final output alone earns only partial credit. A strong answer connects it to “PurePath models path syntax and does not offer concrete filesystem classification.”, shows the relevant intermediate evidence and states why expecting a PurePath to query a live disk would lead to a different conclusion.

Decision and transfer

Choose PurePath for lexical transformations and Path for classification. Prefer the choice whose semantics and failure modes are easiest to explain for the actual job. Shorter syntax is useful only when it preserves that clarity.

Mastery of “PurePath cannot inspect junctions” means the learner can predict the ordinary case, recognise expecting a PurePath to query a live disk, diagnose the earliest mistaken assumption, recover with “Use PureWindowsPath for syntax examples and Path on the target Windows system for observation.” and defend this decision: Choose PurePath for lexical transformations and Path for classification. Once that causal chain is stable, continue to the next chapter rather than adding repetitions of the same surface exercise.

Previous section · Contents · Next section

CHAPTER 12 OF 20 · Test the boundary

12. A Windows shortcut file is not a junction

Back to contents

A .lnk shortcut is an ordinary file interpreted by shell software, not a directory junction. That is the invariant to preserve when names, data or surrounding project details change.

User-interface navigation and filesystem redirection occur at different layers. The useful question is not “Which line should I copy?” but “Which state, value or rendering decision does this operation control?” Answering that question prevents a correct-looking result from hiding a wrong mental model.

The most revealing near-miss is grouping shortcuts, symlinks and junctions under one informal word. A learner should predict the result first, run the smallest safe case, label the observation and explain the earliest point where the prediction diverges. This turns an error into evidence rather than a verdict on ability.

Core worked example

shortcut=Path('project.lnk')
print(shortcut.is_junction())

Explained result. An ordinary shortcut file does not become a junction merely because Explorer can follow it. The explanation should identify the input, the governing rule, the observable outcome and one boundary that would change the conclusion. If any of those four parts is missing, reduce the example and trace it again.

Read the trace, not just the last line

Trace filename extension, file type and junction predicate. Write the trace as a sequence of labelled states. For Python pathlib.Path.is_junction, inspect resolved pathnames, stat identities, exception types and before-and-after directory listings; a single final value can hide the mechanism that produced it.

For “A Windows shortcut file is not a junction”, separate contract from coincidence. The contract is “A .lnk shortcut is an ordinary file interpreted by shell software, not a directory junction.” and comes from the primary specification or manual. Coincidence is what happened on one machine, font, filesystem or repository. Record both, then use “Create only a harmless placeholder when demonstrating the classification distinction.” to decide whether another observation challenges the model or merely reflects the environment.

Four purposeful transfer cases

Case 1: homework export guard. Model “A Windows shortcut file is not a junction” with an input document, two path spellings and a proposed output. Before touching a tool, state which part of the case corresponds to the input, why “A .lnk shortcut is an ordinary file interpreted by shell software, not a directory junction.” should remain invariant and what observation would expose grouping shortcuts, symlinks and junctions under one informal word.

Reasoned route. Begin with “A .lnk shortcut is an ordinary file interpreted by shell software, not a directory junction.” Apply this procedure: Create only a harmless placeholder when demonstrating the classification distinction. For the homework export guard, introduce one controlled variation that exposes grouping shortcuts, symlinks and junctions under one informal word. An ordinary shortcut file does not become a junction merely because Explorer can follow it. A complete answer explains why the near-miss fails, names the evidence that distinguishes it from the corrected case and transfers the rule without relying on the original variable names.

Case 2: photo-library alias check. Contrast “A Windows shortcut file is not a junction” with original files, hard-link aliases and independent copies. Before touching a tool, state which part of the case corresponds to the input, why “A .lnk shortcut is an ordinary file interpreted by shell software, not a directory junction.” should remain invariant and what observation would expose grouping shortcuts, symlinks and junctions under one informal word.

Reasoned route. Begin with “A .lnk shortcut is an ordinary file interpreted by shell software, not a directory junction.” Apply this procedure: Create only a harmless placeholder when demonstrating the classification distinction. For the photo-library alias check, introduce one controlled variation that exposes grouping shortcuts, symlinks and junctions under one informal word. An ordinary shortcut file does not become a junction merely because Explorer can follow it. A complete answer explains why the near-miss fails, names the evidence that distinguishes it from the corrected case and transfers the rule without relying on the original variable names.

Case 3: science-data archive. Stress-test “A Windows shortcut file is not a junction” with raw readings, a symlinked working folder and a missing target. Before touching a tool, state which part of the case corresponds to the input, why “A .lnk shortcut is an ordinary file interpreted by shell software, not a directory junction.” should remain invariant and what observation would expose grouping shortcuts, symlinks and junctions under one informal word.

Reasoned route. Begin with “A .lnk shortcut is an ordinary file interpreted by shell software, not a directory junction.” Apply this procedure: Create only a harmless placeholder when demonstrating the classification distinction. For the science-data archive, introduce one controlled variation that exposes grouping shortcuts, symlinks and junctions under one informal word. An ordinary shortcut file does not become a junction merely because Explorer can follow it. A complete answer explains why the near-miss fails, names the evidence that distinguishes it from the corrected case and transfers the rule without relying on the original variable names.

Case 4: backup verification task. Explain “A Windows shortcut file is not a junction” with source directories, mounted destinations and privacy-safe diagnostics. Before touching a tool, state which part of the case corresponds to the input, why “A .lnk shortcut is an ordinary file interpreted by shell software, not a directory junction.” should remain invariant and what observation would expose grouping shortcuts, symlinks and junctions under one informal word.

Reasoned route. Begin with “A .lnk shortcut is an ordinary file interpreted by shell software, not a directory junction.” Apply this procedure: Create only a harmless placeholder when demonstrating the classification distinction. For the backup verification task, introduce one controlled variation that exposes grouping shortcuts, symlinks and junctions under one informal word. An ordinary shortcut file does not become a junction merely because Explorer can follow it. A complete answer explains why the near-miss fails, names the evidence that distinguishes it from the corrected case and transfers the rule without relying on the original variable names.

Diagnostic route

  • Model check: draw or list the exact values, objects, paths, characters or repository states before the operation.
  • Boundary check: construct the smallest safe input that reveals grouping shortcuts, symlinks and junctions under one informal word.
  • Evidence check: distinguish a displayed result from ownership, caching, consumption, font behaviour or object type.
  • Repair check: Create only a harmless placeholder when demonstrating the classification distinction.
  • Transfer check: repeat the rule in a second context and name what remains unchanged.

A parent does not need to memorise Python pathlib.Path.is_junction to support “A Windows shortcut file is not a junction”. Useful prompts are: “What did you expect?”, “Which state changed first?”, “What evidence tests A .lnk shortcut is an ordinary file interpreted by shell software, not a directory junction.?”, and “Can you make a smaller example of grouping shortcuts, symlinks and junctions under one informal word?” These questions keep ownership with the learner while making the reasoning visible.

Practice with an explained answer

Task. Explain why the extension is not proof. Write the prediction before running anything. Include one ordinary case and one boundary case, then explain the difference in two causal sentences.

Answer route. The shell may interpret .lnk, while Path.is_junction tests filesystem metadata. The final output alone earns only partial credit. A strong answer connects it to “A .lnk shortcut is an ordinary file interpreted by shell software, not a directory junction.”, shows the relevant intermediate evidence and states why grouping shortcuts, symlinks and junctions under one informal word would lead to a different conclusion.

Decision and transfer

Use mechanism names rather than the word link alone. Prefer the choice whose semantics and failure modes are easiest to explain for the actual job. Shorter syntax is useful only when it preserves that clarity.

Mastery of “A Windows shortcut file is not a junction” means the learner can predict the ordinary case, recognise grouping shortcuts, symlinks and junctions under one informal word, diagnose the earliest mistaken assumption, recover with “Create only a harmless placeholder when demonstrating the classification distinction.” and defend this decision: Use mechanism names rather than the word link alone. Once that causal chain is stable, continue to the next chapter rather than adding repetitions of the same surface exercise.

Previous section · Contents · Next section

CHAPTER 13 OF 20 · Diagnose and repair

13. Creation and detection are separate operations

Back to contents

Path.is_junction detects a junction; it does not create one. That is the invariant to preserve when names, data or surrounding project details change.

Inspection methods should not be mistaken for mutation commands. The useful question is not “Which line should I copy?” but “Which state, value or rendering decision does this operation control?” Answering that question prevents a correct-looking result from hiding a wrong mental model.

The most revealing near-miss is looking for a target argument or creation side effect. A learner should predict the result first, run the smallest safe case, label the observation and explain the earliest point where the prediction diverges. This turns an error into evidence rather than a verdict on ability.

Core worked example

if path.is_junction():
    print('junction detected')

Explained result. The call observes current classification and leaves the path unchanged. The explanation should identify the input, the governing rule, the observable outcome and one boundary that would change the conclusion. If any of those four parts is missing, reduce the example and trace it again.

Read the trace, not just the last line

Trace external fixture creation and Python observation as separate steps. Write the trace as a sequence of labelled states. For Python pathlib.Path.is_junction, inspect resolved pathnames, stat identities, exception types and before-and-after directory listings; a single final value can hide the mechanism that produced it.

For “Creation and detection are separate operations”, separate contract from coincidence. The contract is “Path.is_junction detects a junction; it does not create one.” and comes from the primary specification or manual. Coincidence is what happened on one machine, font, filesystem or repository. Record both, then use “Create any positive fixture with documented Windows tooling in a disposable directory, then detect it with Python.” to decide whether another observation challenges the model or merely reflects the environment.

Four purposeful transfer cases

Case 1: homework export guard. Model “Creation and detection are separate operations” with an input document, two path spellings and a proposed output. Before touching a tool, state which part of the case corresponds to the input, why “Path.is_junction detects a junction; it does not create one.” should remain invariant and what observation would expose looking for a target argument or creation side effect.

Reasoned route. Begin with “Path.is_junction detects a junction; it does not create one.” Apply this procedure: Create any positive fixture with documented Windows tooling in a disposable directory, then detect it with Python. For the homework export guard, introduce one controlled variation that exposes looking for a target argument or creation side effect. The call observes current classification and leaves the path unchanged. A complete answer explains why the near-miss fails, names the evidence that distinguishes it from the corrected case and transfers the rule without relying on the original variable names.

Case 2: photo-library alias check. Contrast “Creation and detection are separate operations” with original files, hard-link aliases and independent copies. Before touching a tool, state which part of the case corresponds to the input, why “Path.is_junction detects a junction; it does not create one.” should remain invariant and what observation would expose looking for a target argument or creation side effect.

Reasoned route. Begin with “Path.is_junction detects a junction; it does not create one.” Apply this procedure: Create any positive fixture with documented Windows tooling in a disposable directory, then detect it with Python. For the photo-library alias check, introduce one controlled variation that exposes looking for a target argument or creation side effect. The call observes current classification and leaves the path unchanged. A complete answer explains why the near-miss fails, names the evidence that distinguishes it from the corrected case and transfers the rule without relying on the original variable names.

Case 3: science-data archive. Stress-test “Creation and detection are separate operations” with raw readings, a symlinked working folder and a missing target. Before touching a tool, state which part of the case corresponds to the input, why “Path.is_junction detects a junction; it does not create one.” should remain invariant and what observation would expose looking for a target argument or creation side effect.

Reasoned route. Begin with “Path.is_junction detects a junction; it does not create one.” Apply this procedure: Create any positive fixture with documented Windows tooling in a disposable directory, then detect it with Python. For the science-data archive, introduce one controlled variation that exposes looking for a target argument or creation side effect. The call observes current classification and leaves the path unchanged. A complete answer explains why the near-miss fails, names the evidence that distinguishes it from the corrected case and transfers the rule without relying on the original variable names.

Case 4: backup verification task. Explain “Creation and detection are separate operations” with source directories, mounted destinations and privacy-safe diagnostics. Before touching a tool, state which part of the case corresponds to the input, why “Path.is_junction detects a junction; it does not create one.” should remain invariant and what observation would expose looking for a target argument or creation side effect.

Reasoned route. Begin with “Path.is_junction detects a junction; it does not create one.” Apply this procedure: Create any positive fixture with documented Windows tooling in a disposable directory, then detect it with Python. For the backup verification task, introduce one controlled variation that exposes looking for a target argument or creation side effect. The call observes current classification and leaves the path unchanged. A complete answer explains why the near-miss fails, names the evidence that distinguishes it from the corrected case and transfers the rule without relying on the original variable names.

Diagnostic route

  • Model check: draw or list the exact values, objects, paths, characters or repository states before the operation.
  • Boundary check: construct the smallest safe input that reveals looking for a target argument or creation side effect.
  • Evidence check: distinguish a displayed result from ownership, caching, consumption, font behaviour or object type.
  • Repair check: Create any positive fixture with documented Windows tooling in a disposable directory, then detect it with Python.
  • Transfer check: repeat the rule in a second context and name what remains unchanged.

A parent does not need to memorise Python pathlib.Path.is_junction to support “Creation and detection are separate operations”. Useful prompts are: “What did you expect?”, “Which state changed first?”, “What evidence tests Path.is_junction detects a junction; it does not create one.?”, and “Can you make a smaller example of looking for a target argument or creation side effect?” These questions keep ownership with the learner while making the reasoning visible.

Practice with an explained answer

Task. Call is_junction twice. Write the prediction before running anything. Include one ordinary case and one boundary case, then explain the difference in two causal sentences.

Answer route. Repeated observation does not create or retarget the junction. The final output alone earns only partial credit. A strong answer connects it to “Path.is_junction detects a junction; it does not create one.”, shows the relevant intermediate evidence and states why looking for a target argument or creation side effect would lead to a different conclusion.

Decision and transfer

Keep setup, detection and cleanup phases distinct. Prefer the choice whose semantics and failure modes are easiest to explain for the actual job. Shorter syntax is useful only when it preserves that clarity.

Mastery of “Creation and detection are separate operations” means the learner can predict the ordinary case, recognise looking for a target argument or creation side effect, diagnose the earliest mistaken assumption, recover with “Create any positive fixture with documented Windows tooling in a disposable directory, then detect it with Python.” and defend this decision: Keep setup, detection and cleanup phases distinct. Once that causal chain is stable, continue to the next chapter rather than adding repetitions of the same surface exercise.

Previous section · Contents · Next section

CHAPTER 14 OF 20 · Diagnose and repair

14. Recursive walkers need an explicit junction policy

Back to contents

A directory walker can cross a junction into another tree unless the application deliberately fences traversal. That is the invariant to preserve when names, data or surrounding project details change.

Redirection can expand scope beyond the visible starting tree. The useful question is not “Which line should I copy?” but “Which state, value or rendering decision does this operation control?” Answering that question prevents a correct-looking result from hiding a wrong mental model.

The most revealing near-miss is recursing first and checking boundaries later. A learner should predict the result first, run the smallest safe case, label the observation and explain the earliest point where the prediction diverges. This turns an error into evidence rather than a verdict on ability.

Core worked example

for child in root.iterdir():
    if child.is_junction():
        print('review boundary', child)

Explained result. The classifier can support a stop, log or allow decision before descent. The explanation should identify the input, the governing rule, the observable outcome and one boundary that would change the conclusion. If any of those four parts is missing, reduce the example and trace it again.

Read the trace, not just the last line

Trace current entry, classification, policy and next path. Write the trace as a sequence of labelled states. For Python pathlib.Path.is_junction, inspect resolved pathnames, stat identities, exception types and before-and-after directory listings; a single final value can hide the mechanism that produced it.

For “Recursive walkers need an explicit junction policy”, separate contract from coincidence. The contract is “A directory walker can cross a junction into another tree unless the application deliberately fences traversal.” and comes from the primary specification or manual. Coincidence is what happened on one machine, font, filesystem or repository. Record both, then use “Use a shallow disposable tree and record every proposed descent before acting.” to decide whether another observation challenges the model or merely reflects the environment.

Four purposeful transfer cases

Case 1: homework export guard. Model “Recursive walkers need an explicit junction policy” with an input document, two path spellings and a proposed output. Before touching a tool, state which part of the case corresponds to the input, why “A directory walker can cross a junction into another tree unless the application deliberately fences traversal.” should remain invariant and what observation would expose recursing first and checking boundaries later.

Reasoned route. Begin with “A directory walker can cross a junction into another tree unless the application deliberately fences traversal.” Apply this procedure: Use a shallow disposable tree and record every proposed descent before acting. For the homework export guard, introduce one controlled variation that exposes recursing first and checking boundaries later. The classifier can support a stop, log or allow decision before descent. A complete answer explains why the near-miss fails, names the evidence that distinguishes it from the corrected case and transfers the rule without relying on the original variable names.

Case 2: photo-library alias check. Contrast “Recursive walkers need an explicit junction policy” with original files, hard-link aliases and independent copies. Before touching a tool, state which part of the case corresponds to the input, why “A directory walker can cross a junction into another tree unless the application deliberately fences traversal.” should remain invariant and what observation would expose recursing first and checking boundaries later.

Reasoned route. Begin with “A directory walker can cross a junction into another tree unless the application deliberately fences traversal.” Apply this procedure: Use a shallow disposable tree and record every proposed descent before acting. For the photo-library alias check, introduce one controlled variation that exposes recursing first and checking boundaries later. The classifier can support a stop, log or allow decision before descent. A complete answer explains why the near-miss fails, names the evidence that distinguishes it from the corrected case and transfers the rule without relying on the original variable names.

Case 3: science-data archive. Stress-test “Recursive walkers need an explicit junction policy” with raw readings, a symlinked working folder and a missing target. Before touching a tool, state which part of the case corresponds to the input, why “A directory walker can cross a junction into another tree unless the application deliberately fences traversal.” should remain invariant and what observation would expose recursing first and checking boundaries later.

Reasoned route. Begin with “A directory walker can cross a junction into another tree unless the application deliberately fences traversal.” Apply this procedure: Use a shallow disposable tree and record every proposed descent before acting. For the science-data archive, introduce one controlled variation that exposes recursing first and checking boundaries later. The classifier can support a stop, log or allow decision before descent. A complete answer explains why the near-miss fails, names the evidence that distinguishes it from the corrected case and transfers the rule without relying on the original variable names.

Case 4: backup verification task. Explain “Recursive walkers need an explicit junction policy” with source directories, mounted destinations and privacy-safe diagnostics. Before touching a tool, state which part of the case corresponds to the input, why “A directory walker can cross a junction into another tree unless the application deliberately fences traversal.” should remain invariant and what observation would expose recursing first and checking boundaries later.

Reasoned route. Begin with “A directory walker can cross a junction into another tree unless the application deliberately fences traversal.” Apply this procedure: Use a shallow disposable tree and record every proposed descent before acting. For the backup verification task, introduce one controlled variation that exposes recursing first and checking boundaries later. The classifier can support a stop, log or allow decision before descent. A complete answer explains why the near-miss fails, names the evidence that distinguishes it from the corrected case and transfers the rule without relying on the original variable names.

Diagnostic route

  • Model check: draw or list the exact values, objects, paths, characters or repository states before the operation.
  • Boundary check: construct the smallest safe input that reveals recursing first and checking boundaries later.
  • Evidence check: distinguish a displayed result from ownership, caching, consumption, font behaviour or object type.
  • Repair check: Use a shallow disposable tree and record every proposed descent before acting.
  • Transfer check: repeat the rule in a second context and name what remains unchanged.

A parent does not need to memorise Python pathlib.Path.is_junction to support “Recursive walkers need an explicit junction policy”. Useful prompts are: “What did you expect?”, “Which state changed first?”, “What evidence tests A directory walker can cross a junction into another tree unless the application deliberately fences traversal.?”, and “Can you make a smaller example of recursing first and checking boundaries later?” These questions keep ownership with the learner while making the reasoning visible.

Practice with an explained answer

Task. Design stop and allow modes. Write the prediction before running anything. Include one ordinary case and one boundary case, then explain the difference in two causal sentences.

Answer route. Both modes should report the junction and make the policy visible. The final output alone earns only partial credit. A strong answer connects it to “A directory walker can cross a junction into another tree unless the application deliberately fences traversal.”, shows the relevant intermediate evidence and states why recursing first and checking boundaries later would lead to a different conclusion.

Decision and transfer

Default destructive tools to the smallest reviewed scope. Prefer the choice whose semantics and failure modes are easiest to explain for the actual job. Shorter syntax is useful only when it preserves that clarity.

Mastery of “Recursive walkers need an explicit junction policy” means the learner can predict the ordinary case, recognise recursing first and checking boundaries later, diagnose the earliest mistaken assumption, recover with “Use a shallow disposable tree and record every proposed descent before acting.” and defend this decision: Default destructive tools to the smallest reviewed scope. Once that causal chain is stable, continue to the next chapter rather than adding repetitions of the same surface exercise.

Previous section · Contents · Next section

CHAPTER 15 OF 20 · Diagnose and repair

15. Backup tools must distinguish identity from policy

Back to contents

Detecting a junction does not by itself decide whether its target belongs in a backup. That is the invariant to preserve when names, data or surrounding project details change.

Ownership, target scope and duplicate handling require additional evidence. The useful question is not “Which line should I copy?” but “Which state, value or rendering decision does this operation control?” Answering that question prevents a correct-looking result from hiding a wrong mental model.

The most revealing near-miss is turning one predicate into a complete backup strategy. A learner should predict the result first, run the smallest safe case, label the observation and explain the earliest point where the prediction diverges. This turns an error into evidence rather than a verdict on ability.

Core worked example

kind='junction' if p.is_junction() else 'other'
print(kind)

Explained result. The method supplies one fact; inclusion, exclusion and deduplication remain application decisions. The explanation should identify the input, the governing rule, the observable outcome and one boundary that would change the conclusion. If any of those four parts is missing, reduce the example and trace it again.

Read the trace, not just the last line

Trace classification, target policy and planned operation. Write the trace as a sequence of labelled states. For Python pathlib.Path.is_junction, inspect resolved pathnames, stat identities, exception types and before-and-after directory listings; a single final value can hide the mechanism that produced it.

For “Backup tools must distinguish identity from policy”, separate contract from coincidence. The contract is “Detecting a junction does not by itself decide whether its target belongs in a backup.” and comes from the primary specification or manual. Coincidence is what happened on one machine, font, filesystem or repository. Record both, then use “Write a decision table before copying any files.” to decide whether another observation challenges the model or merely reflects the environment.

Four purposeful transfer cases

Case 1: homework export guard. Model “Backup tools must distinguish identity from policy” with an input document, two path spellings and a proposed output. Before touching a tool, state which part of the case corresponds to the input, why “Detecting a junction does not by itself decide whether its target belongs in a backup.” should remain invariant and what observation would expose turning one predicate into a complete backup strategy.

Reasoned route. Begin with “Detecting a junction does not by itself decide whether its target belongs in a backup.” Apply this procedure: Write a decision table before copying any files. For the homework export guard, introduce one controlled variation that exposes turning one predicate into a complete backup strategy. The method supplies one fact; inclusion, exclusion and deduplication remain application decisions. A complete answer explains why the near-miss fails, names the evidence that distinguishes it from the corrected case and transfers the rule without relying on the original variable names.

Case 2: photo-library alias check. Contrast “Backup tools must distinguish identity from policy” with original files, hard-link aliases and independent copies. Before touching a tool, state which part of the case corresponds to the input, why “Detecting a junction does not by itself decide whether its target belongs in a backup.” should remain invariant and what observation would expose turning one predicate into a complete backup strategy.

Reasoned route. Begin with “Detecting a junction does not by itself decide whether its target belongs in a backup.” Apply this procedure: Write a decision table before copying any files. For the photo-library alias check, introduce one controlled variation that exposes turning one predicate into a complete backup strategy. The method supplies one fact; inclusion, exclusion and deduplication remain application decisions. A complete answer explains why the near-miss fails, names the evidence that distinguishes it from the corrected case and transfers the rule without relying on the original variable names.

Case 3: science-data archive. Stress-test “Backup tools must distinguish identity from policy” with raw readings, a symlinked working folder and a missing target. Before touching a tool, state which part of the case corresponds to the input, why “Detecting a junction does not by itself decide whether its target belongs in a backup.” should remain invariant and what observation would expose turning one predicate into a complete backup strategy.

Reasoned route. Begin with “Detecting a junction does not by itself decide whether its target belongs in a backup.” Apply this procedure: Write a decision table before copying any files. For the science-data archive, introduce one controlled variation that exposes turning one predicate into a complete backup strategy. The method supplies one fact; inclusion, exclusion and deduplication remain application decisions. A complete answer explains why the near-miss fails, names the evidence that distinguishes it from the corrected case and transfers the rule without relying on the original variable names.

Case 4: backup verification task. Explain “Backup tools must distinguish identity from policy” with source directories, mounted destinations and privacy-safe diagnostics. Before touching a tool, state which part of the case corresponds to the input, why “Detecting a junction does not by itself decide whether its target belongs in a backup.” should remain invariant and what observation would expose turning one predicate into a complete backup strategy.

Reasoned route. Begin with “Detecting a junction does not by itself decide whether its target belongs in a backup.” Apply this procedure: Write a decision table before copying any files. For the backup verification task, introduce one controlled variation that exposes turning one predicate into a complete backup strategy. The method supplies one fact; inclusion, exclusion and deduplication remain application decisions. A complete answer explains why the near-miss fails, names the evidence that distinguishes it from the corrected case and transfers the rule without relying on the original variable names.

Diagnostic route

  • Model check: draw or list the exact values, objects, paths, characters or repository states before the operation.
  • Boundary check: construct the smallest safe input that reveals turning one predicate into a complete backup strategy.
  • Evidence check: distinguish a displayed result from ownership, caching, consumption, font behaviour or object type.
  • Repair check: Write a decision table before copying any files.
  • Transfer check: repeat the rule in a second context and name what remains unchanged.

A parent does not need to memorise Python pathlib.Path.is_junction to support “Backup tools must distinguish identity from policy”. Useful prompts are: “What did you expect?”, “Which state changed first?”, “What evidence tests Detecting a junction does not by itself decide whether its target belongs in a backup.?”, and “Can you make a smaller example of turning one predicate into a complete backup strategy?” These questions keep ownership with the learner while making the reasoning visible.

Practice with an explained answer

Task. Evaluate a junction inside the source tree. Write the prediction before running anything. Include one ordinary case and one boundary case, then explain the difference in two causal sentences.

Answer route. A safe plan can log it and request or apply a declared rule. The final output alone earns only partial credit. A strong answer connects it to “Detecting a junction does not by itself decide whether its target belongs in a backup.”, shows the relevant intermediate evidence and states why turning one predicate into a complete backup strategy would lead to a different conclusion.

Decision and transfer

Separate observation from permission to traverse. Prefer the choice whose semantics and failure modes are easiest to explain for the actual job. Shorter syntax is useful only when it preserves that clarity.

Mastery of “Backup tools must distinguish identity from policy” means the learner can predict the ordinary case, recognise turning one predicate into a complete backup strategy, diagnose the earliest mistaken assumption, recover with “Write a decision table before copying any files.” and defend this decision: Separate observation from permission to traverse. Once that causal chain is stable, continue to the next chapter rather than adding repetitions of the same surface exercise.

Previous section · Contents · Next section

CHAPTER 16 OF 20 · Diagnose and repair

16. Deletion previews should stop before target assumptions

Back to contents

A junction classification can trigger a review before a recursive delete chooses its scope. That is the invariant to preserve when names, data or surrounding project details change.

Removal semantics vary by platform and operation. The useful question is not “Which line should I copy?” but “Which state, value or rendering decision does this operation control?” Answering that question prevents a correct-looking result from hiding a wrong mental model.

The most revealing near-miss is using the guard as proof that every deletion API behaves identically. A learner should predict the result first, run the smallest safe case, label the observation and explain the earliest point where the prediction diverges. This turns an error into evidence rather than a verdict on ability.

Core worked example

if candidate.is_junction():
    raise RuntimeError('review junction before deletion')

Explained result. The guard prevents the example from treating the entry as an ordinary owned subtree. The explanation should identify the input, the governing rule, the observable outcome and one boundary that would change the conclusion. If any of those four parts is missing, reduce the example and trace it again.

Read the trace, not just the last line

Trace candidate, predicate, guard and zero-mutation outcome. Write the trace as a sequence of labelled states. For Python pathlib.Path.is_junction, inspect resolved pathnames, stat identities, exception types and before-and-after directory listings; a single final value can hide the mechanism that produced it.

For “Deletion previews should stop before target assumptions”, separate contract from coincidence. The contract is “A junction classification can trigger a review before a recursive delete chooses its scope.” and comes from the primary specification or manual. Coincidence is what happened on one machine, font, filesystem or repository. Record both, then use “Perform only dry-run listing in the learning fixture.” to decide whether another observation challenges the model or merely reflects the environment.

Four purposeful transfer cases

Case 1: homework export guard. Model “Deletion previews should stop before target assumptions” with an input document, two path spellings and a proposed output. Before touching a tool, state which part of the case corresponds to the input, why “A junction classification can trigger a review before a recursive delete chooses its scope.” should remain invariant and what observation would expose using the guard as proof that every deletion API behaves identically.

Reasoned route. Begin with “A junction classification can trigger a review before a recursive delete chooses its scope.” Apply this procedure: Perform only dry-run listing in the learning fixture. For the homework export guard, introduce one controlled variation that exposes using the guard as proof that every deletion API behaves identically. The guard prevents the example from treating the entry as an ordinary owned subtree. A complete answer explains why the near-miss fails, names the evidence that distinguishes it from the corrected case and transfers the rule without relying on the original variable names.

Case 2: photo-library alias check. Contrast “Deletion previews should stop before target assumptions” with original files, hard-link aliases and independent copies. Before touching a tool, state which part of the case corresponds to the input, why “A junction classification can trigger a review before a recursive delete chooses its scope.” should remain invariant and what observation would expose using the guard as proof that every deletion API behaves identically.

Reasoned route. Begin with “A junction classification can trigger a review before a recursive delete chooses its scope.” Apply this procedure: Perform only dry-run listing in the learning fixture. For the photo-library alias check, introduce one controlled variation that exposes using the guard as proof that every deletion API behaves identically. The guard prevents the example from treating the entry as an ordinary owned subtree. A complete answer explains why the near-miss fails, names the evidence that distinguishes it from the corrected case and transfers the rule without relying on the original variable names.

Case 3: science-data archive. Stress-test “Deletion previews should stop before target assumptions” with raw readings, a symlinked working folder and a missing target. Before touching a tool, state which part of the case corresponds to the input, why “A junction classification can trigger a review before a recursive delete chooses its scope.” should remain invariant and what observation would expose using the guard as proof that every deletion API behaves identically.

Reasoned route. Begin with “A junction classification can trigger a review before a recursive delete chooses its scope.” Apply this procedure: Perform only dry-run listing in the learning fixture. For the science-data archive, introduce one controlled variation that exposes using the guard as proof that every deletion API behaves identically. The guard prevents the example from treating the entry as an ordinary owned subtree. A complete answer explains why the near-miss fails, names the evidence that distinguishes it from the corrected case and transfers the rule without relying on the original variable names.

Case 4: backup verification task. Explain “Deletion previews should stop before target assumptions” with source directories, mounted destinations and privacy-safe diagnostics. Before touching a tool, state which part of the case corresponds to the input, why “A junction classification can trigger a review before a recursive delete chooses its scope.” should remain invariant and what observation would expose using the guard as proof that every deletion API behaves identically.

Reasoned route. Begin with “A junction classification can trigger a review before a recursive delete chooses its scope.” Apply this procedure: Perform only dry-run listing in the learning fixture. For the backup verification task, introduce one controlled variation that exposes using the guard as proof that every deletion API behaves identically. The guard prevents the example from treating the entry as an ordinary owned subtree. A complete answer explains why the near-miss fails, names the evidence that distinguishes it from the corrected case and transfers the rule without relying on the original variable names.

Diagnostic route

  • Model check: draw or list the exact values, objects, paths, characters or repository states before the operation.
  • Boundary check: construct the smallest safe input that reveals using the guard as proof that every deletion API behaves identically.
  • Evidence check: distinguish a displayed result from ownership, caching, consumption, font behaviour or object type.
  • Repair check: Perform only dry-run listing in the learning fixture.
  • Transfer check: repeat the rule in a second context and name what remains unchanged.

A parent does not need to memorise Python pathlib.Path.is_junction to support “Deletion previews should stop before target assumptions”. Useful prompts are: “What did you expect?”, “Which state changed first?”, “What evidence tests A junction classification can trigger a review before a recursive delete chooses its scope.?”, and “Can you make a smaller example of using the guard as proof that every deletion API behaves identically?” These questions keep ownership with the learner while making the reasoning visible.

Practice with an explained answer

Task. Write a deletion preview report. Write the prediction before running anything. Include one ordinary case and one boundary case, then explain the difference in two causal sentences.

Answer route. The report names the boundary without deleting the entry or target. The final output alone earns only partial credit. A strong answer connects it to “A junction classification can trigger a review before a recursive delete chooses its scope.”, shows the relevant intermediate evidence and states why using the guard as proof that every deletion API behaves identically would lead to a different conclusion.

Decision and transfer

Use platform documentation for any real removal operation. Prefer the choice whose semantics and failure modes are easiest to explain for the actual job. Shorter syntax is useful only when it preserves that clarity.

Mastery of “Deletion previews should stop before target assumptions” means the learner can predict the ordinary case, recognise using the guard as proof that every deletion API behaves identically, diagnose the earliest mistaken assumption, recover with “Perform only dry-run listing in the learning fixture.” and defend this decision: Use platform documentation for any real removal operation. Once that causal chain is stable, continue to the next chapter rather than adding repetitions of the same surface exercise.

Previous section · Contents · Next section

CHAPTER 17 OF 20 · Transfer with judgment

17. Non-Windows tests should skip positive assertions honestly

Back to contents

A positive junction fixture cannot be validated on a platform that does not support Windows junctions. That is the invariant to preserve when names, data or surrounding project details change.

A mock can test branching code but not operating-system metadata. The useful question is not “Which line should I copy?” but “Which state, value or rendering decision does this operation control?” Answering that question prevents a correct-looking result from hiding a wrong mental model.

The most revealing near-miss is mocking a Boolean and calling the filesystem contract tested. A learner should predict the result first, run the smallest safe case, label the observation and explain the earliest point where the prediction diverges. This turns an error into evidence rather than a verdict on ability.

Core worked example

import os, pytest
pytestmark=pytest.mark.skipif(os.name!='nt', reason='Windows junction fixture')

Explained result. The test suite records why the positive case is skipped rather than claiming portable success. The explanation should identify the input, the governing rule, the observable outcome and one boundary that would change the conclusion. If any of those four parts is missing, reduce the example and trace it again.

Read the trace, not just the last line

Trace platform gate, fixture capability and assertion layer. Write the trace as a sequence of labelled states. For Python pathlib.Path.is_junction, inspect resolved pathnames, stat identities, exception types and before-and-after directory listings; a single final value can hide the mechanism that produced it.

For “Non-Windows tests should skip positive assertions honestly”, separate contract from coincidence. The contract is “A positive junction fixture cannot be validated on a platform that does not support Windows junctions.” and comes from the primary specification or manual. Coincidence is what happened on one machine, font, filesystem or repository. Record both, then use “Separate pure decision tests from Windows integration tests.” to decide whether another observation challenges the model or merely reflects the environment.

Four purposeful transfer cases

Case 1: homework export guard. Model “Non-Windows tests should skip positive assertions honestly” with an input document, two path spellings and a proposed output. Before touching a tool, state which part of the case corresponds to the input, why “A positive junction fixture cannot be validated on a platform that does not support Windows junctions.” should remain invariant and what observation would expose mocking a Boolean and calling the filesystem contract tested.

Reasoned route. Begin with “A positive junction fixture cannot be validated on a platform that does not support Windows junctions.” Apply this procedure: Separate pure decision tests from Windows integration tests. For the homework export guard, introduce one controlled variation that exposes mocking a Boolean and calling the filesystem contract tested. The test suite records why the positive case is skipped rather than claiming portable success. A complete answer explains why the near-miss fails, names the evidence that distinguishes it from the corrected case and transfers the rule without relying on the original variable names.

Case 2: photo-library alias check. Contrast “Non-Windows tests should skip positive assertions honestly” with original files, hard-link aliases and independent copies. Before touching a tool, state which part of the case corresponds to the input, why “A positive junction fixture cannot be validated on a platform that does not support Windows junctions.” should remain invariant and what observation would expose mocking a Boolean and calling the filesystem contract tested.

Reasoned route. Begin with “A positive junction fixture cannot be validated on a platform that does not support Windows junctions.” Apply this procedure: Separate pure decision tests from Windows integration tests. For the photo-library alias check, introduce one controlled variation that exposes mocking a Boolean and calling the filesystem contract tested. The test suite records why the positive case is skipped rather than claiming portable success. A complete answer explains why the near-miss fails, names the evidence that distinguishes it from the corrected case and transfers the rule without relying on the original variable names.

Case 3: science-data archive. Stress-test “Non-Windows tests should skip positive assertions honestly” with raw readings, a symlinked working folder and a missing target. Before touching a tool, state which part of the case corresponds to the input, why “A positive junction fixture cannot be validated on a platform that does not support Windows junctions.” should remain invariant and what observation would expose mocking a Boolean and calling the filesystem contract tested.

Reasoned route. Begin with “A positive junction fixture cannot be validated on a platform that does not support Windows junctions.” Apply this procedure: Separate pure decision tests from Windows integration tests. For the science-data archive, introduce one controlled variation that exposes mocking a Boolean and calling the filesystem contract tested. The test suite records why the positive case is skipped rather than claiming portable success. A complete answer explains why the near-miss fails, names the evidence that distinguishes it from the corrected case and transfers the rule without relying on the original variable names.

Case 4: backup verification task. Explain “Non-Windows tests should skip positive assertions honestly” with source directories, mounted destinations and privacy-safe diagnostics. Before touching a tool, state which part of the case corresponds to the input, why “A positive junction fixture cannot be validated on a platform that does not support Windows junctions.” should remain invariant and what observation would expose mocking a Boolean and calling the filesystem contract tested.

Reasoned route. Begin with “A positive junction fixture cannot be validated on a platform that does not support Windows junctions.” Apply this procedure: Separate pure decision tests from Windows integration tests. For the backup verification task, introduce one controlled variation that exposes mocking a Boolean and calling the filesystem contract tested. The test suite records why the positive case is skipped rather than claiming portable success. A complete answer explains why the near-miss fails, names the evidence that distinguishes it from the corrected case and transfers the rule without relying on the original variable names.

Diagnostic route

  • Model check: draw or list the exact values, objects, paths, characters or repository states before the operation.
  • Boundary check: construct the smallest safe input that reveals mocking a Boolean and calling the filesystem contract tested.
  • Evidence check: distinguish a displayed result from ownership, caching, consumption, font behaviour or object type.
  • Repair check: Separate pure decision tests from Windows integration tests.
  • Transfer check: repeat the rule in a second context and name what remains unchanged.

A parent does not need to memorise Python pathlib.Path.is_junction to support “Non-Windows tests should skip positive assertions honestly”. Useful prompts are: “What did you expect?”, “Which state changed first?”, “What evidence tests A positive junction fixture cannot be validated on a platform that does not support Windows junctions.?”, and “Can you make a smaller example of mocking a Boolean and calling the filesystem contract tested?” These questions keep ownership with the learner while making the reasoning visible.

Practice with an explained answer

Task. Plan CI coverage. Write the prediction before running anything. Include one ordinary case and one boundary case, then explain the difference in two causal sentences.

Answer route. Run positive integration tests on Windows and negative ordinary-path tests elsewhere. The final output alone earns only partial credit. A strong answer connects it to “A positive junction fixture cannot be validated on a platform that does not support Windows junctions.”, shows the relevant intermediate evidence and states why mocking a Boolean and calling the filesystem contract tested would lead to a different conclusion.

Decision and transfer

Match test claims to observed layers. Prefer the choice whose semantics and failure modes are easiest to explain for the actual job. Shorter syntax is useful only when it preserves that clarity.

Mastery of “Non-Windows tests should skip positive assertions honestly” means the learner can predict the ordinary case, recognise mocking a Boolean and calling the filesystem contract tested, diagnose the earliest mistaken assumption, recover with “Separate pure decision tests from Windows integration tests.” and defend this decision: Match test claims to observed layers. Once that causal chain is stable, continue to the next chapter rather than adding repetitions of the same surface exercise.

Previous section · Contents · Next section

CHAPTER 18 OF 20 · Transfer with judgment

18. Version and platform belong in diagnostics

Back to contents

A useful report records Python version, operating system and the safely labelled path role. That is the invariant to preserve when names, data or surrounding project details change.

Diagnostics can be specific without exposing a pupil name or home directory. The useful question is not “Which line should I copy?” but “Which state, value or rendering decision does this operation control?” Answering that question prevents a correct-looking result from hiding a wrong mental model.

The most revealing near-miss is publishing full private filesystem paths to gain context. A learner should predict the result first, run the smallest safe case, label the observation and explain the earliest point where the prediction diverges. This turns an error into evidence rather than a verdict on ability.

Core worked example

import os, sys
print(sys.version_info[:3], os.name)

Explained result. The report makes an unavailable API or unsupported platform easier to distinguish from a negative path result. The explanation should identify the input, the governing rule, the observable outcome and one boundary that would change the conclusion. If any of those four parts is missing, reduce the example and trace it again.

Read the trace, not just the last line

Trace runtime facts and classification without sensitive path text. Write the trace as a sequence of labelled states. For Python pathlib.Path.is_junction, inspect resolved pathnames, stat identities, exception types and before-and-after directory listings; a single final value can hide the mechanism that produced it.

For “Version and platform belong in diagnostics”, separate contract from coincidence. The contract is “A useful report records Python version, operating system and the safely labelled path role.” and comes from the primary specification or manual. Coincidence is what happened on one machine, font, filesystem or repository. Record both, then use “Use synthetic labels and redacted roots.” to decide whether another observation challenges the model or merely reflects the environment.

Four purposeful transfer cases

Case 1: homework export guard. Model “Version and platform belong in diagnostics” with an input document, two path spellings and a proposed output. Before touching a tool, state which part of the case corresponds to the input, why “A useful report records Python version, operating system and the safely labelled path role.” should remain invariant and what observation would expose publishing full private filesystem paths to gain context.

Reasoned route. Begin with “A useful report records Python version, operating system and the safely labelled path role.” Apply this procedure: Use synthetic labels and redacted roots. For the homework export guard, introduce one controlled variation that exposes publishing full private filesystem paths to gain context. The report makes an unavailable API or unsupported platform easier to distinguish from a negative path result. A complete answer explains why the near-miss fails, names the evidence that distinguishes it from the corrected case and transfers the rule without relying on the original variable names.

Case 2: photo-library alias check. Contrast “Version and platform belong in diagnostics” with original files, hard-link aliases and independent copies. Before touching a tool, state which part of the case corresponds to the input, why “A useful report records Python version, operating system and the safely labelled path role.” should remain invariant and what observation would expose publishing full private filesystem paths to gain context.

Reasoned route. Begin with “A useful report records Python version, operating system and the safely labelled path role.” Apply this procedure: Use synthetic labels and redacted roots. For the photo-library alias check, introduce one controlled variation that exposes publishing full private filesystem paths to gain context. The report makes an unavailable API or unsupported platform easier to distinguish from a negative path result. A complete answer explains why the near-miss fails, names the evidence that distinguishes it from the corrected case and transfers the rule without relying on the original variable names.

Case 3: science-data archive. Stress-test “Version and platform belong in diagnostics” with raw readings, a symlinked working folder and a missing target. Before touching a tool, state which part of the case corresponds to the input, why “A useful report records Python version, operating system and the safely labelled path role.” should remain invariant and what observation would expose publishing full private filesystem paths to gain context.

Reasoned route. Begin with “A useful report records Python version, operating system and the safely labelled path role.” Apply this procedure: Use synthetic labels and redacted roots. For the science-data archive, introduce one controlled variation that exposes publishing full private filesystem paths to gain context. The report makes an unavailable API or unsupported platform easier to distinguish from a negative path result. A complete answer explains why the near-miss fails, names the evidence that distinguishes it from the corrected case and transfers the rule without relying on the original variable names.

Case 4: backup verification task. Explain “Version and platform belong in diagnostics” with source directories, mounted destinations and privacy-safe diagnostics. Before touching a tool, state which part of the case corresponds to the input, why “A useful report records Python version, operating system and the safely labelled path role.” should remain invariant and what observation would expose publishing full private filesystem paths to gain context.

Reasoned route. Begin with “A useful report records Python version, operating system and the safely labelled path role.” Apply this procedure: Use synthetic labels and redacted roots. For the backup verification task, introduce one controlled variation that exposes publishing full private filesystem paths to gain context. The report makes an unavailable API or unsupported platform easier to distinguish from a negative path result. A complete answer explains why the near-miss fails, names the evidence that distinguishes it from the corrected case and transfers the rule without relying on the original variable names.

Diagnostic route

  • Model check: draw or list the exact values, objects, paths, characters or repository states before the operation.
  • Boundary check: construct the smallest safe input that reveals publishing full private filesystem paths to gain context.
  • Evidence check: distinguish a displayed result from ownership, caching, consumption, font behaviour or object type.
  • Repair check: Use synthetic labels and redacted roots.
  • Transfer check: repeat the rule in a second context and name what remains unchanged.

A parent does not need to memorise Python pathlib.Path.is_junction to support “Version and platform belong in diagnostics”. Useful prompts are: “What did you expect?”, “Which state changed first?”, “What evidence tests A useful report records Python version, operating system and the safely labelled path role.?”, and “Can you make a smaller example of publishing full private filesystem paths to gain context?” These questions keep ownership with the learner while making the reasoning visible.

Practice with an explained answer

Task. Write a privacy-safe failure record. Write the prediction before running anything. Include one ordinary case and one boundary case, then explain the difference in two causal sentences.

Answer route. Include platform, version, error category and fixture label. The final output alone earns only partial credit. A strong answer connects it to “A useful report records Python version, operating system and the safely labelled path role.”, shows the relevant intermediate evidence and states why publishing full private filesystem paths to gain context would lead to a different conclusion.

Decision and transfer

Collect only evidence needed for repair. Prefer the choice whose semantics and failure modes are easiest to explain for the actual job. Shorter syntax is useful only when it preserves that clarity.

Mastery of “Version and platform belong in diagnostics” means the learner can predict the ordinary case, recognise publishing full private filesystem paths to gain context, diagnose the earliest mistaken assumption, recover with “Use synthetic labels and redacted roots.” and defend this decision: Collect only evidence needed for repair. Once that causal chain is stable, continue to the next chapter rather than adding repetitions of the same surface exercise.

Previous section · Contents · Next section

CHAPTER 19 OF 20 · Transfer with judgment

19. Repeated classification is not a frozen guarantee

Back to contents

Filesystem state can change after is_junction returns. That is the invariant to preserve when names, data or surrounding project details change.

Time-of-check and time-of-use are separate events. The useful question is not “Which line should I copy?” but “Which state, value or rendering decision does this operation control?” Answering that question prevents a correct-looking result from hiding a wrong mental model.

The most revealing near-miss is treating a check as a permanent security guarantee. A learner should predict the result first, run the smallest safe case, label the observation and explain the earliest point where the prediction diverges. This turns an error into evidence rather than a verdict on ability.

Core worked example

was_junction=path.is_junction()
# state may change before a later operation

Explained result. The Boolean describes the observed moment, not an unchangeable future path. The explanation should identify the input, the governing rule, the observable outcome and one boundary that would change the conclusion. If any of those four parts is missing, reduce the example and trace it again.

Read the trace, not just the last line

Trace check time and later use time. Write the trace as a sequence of labelled states. For Python pathlib.Path.is_junction, inspect resolved pathnames, stat identities, exception types and before-and-after directory listings; a single final value can hide the mechanism that produced it.

For “Repeated classification is not a frozen guarantee”, separate contract from coincidence. The contract is “Filesystem state can change after is_junction returns.” and comes from the primary specification or manual. Coincidence is what happened on one machine, font, filesystem or repository. Record both, then use “Keep learning examples single-process and minimise the gap before a related safe action.” to decide whether another observation challenges the model or merely reflects the environment.

Four purposeful transfer cases

Case 1: homework export guard. Model “Repeated classification is not a frozen guarantee” with an input document, two path spellings and a proposed output. Before touching a tool, state which part of the case corresponds to the input, why “Filesystem state can change after is_junction returns.” should remain invariant and what observation would expose treating a check as a permanent security guarantee.

Reasoned route. Begin with “Filesystem state can change after is_junction returns.” Apply this procedure: Keep learning examples single-process and minimise the gap before a related safe action. For the homework export guard, introduce one controlled variation that exposes treating a check as a permanent security guarantee. The Boolean describes the observed moment, not an unchangeable future path. A complete answer explains why the near-miss fails, names the evidence that distinguishes it from the corrected case and transfers the rule without relying on the original variable names.

Case 2: photo-library alias check. Contrast “Repeated classification is not a frozen guarantee” with original files, hard-link aliases and independent copies. Before touching a tool, state which part of the case corresponds to the input, why “Filesystem state can change after is_junction returns.” should remain invariant and what observation would expose treating a check as a permanent security guarantee.

Reasoned route. Begin with “Filesystem state can change after is_junction returns.” Apply this procedure: Keep learning examples single-process and minimise the gap before a related safe action. For the photo-library alias check, introduce one controlled variation that exposes treating a check as a permanent security guarantee. The Boolean describes the observed moment, not an unchangeable future path. A complete answer explains why the near-miss fails, names the evidence that distinguishes it from the corrected case and transfers the rule without relying on the original variable names.

Case 3: science-data archive. Stress-test “Repeated classification is not a frozen guarantee” with raw readings, a symlinked working folder and a missing target. Before touching a tool, state which part of the case corresponds to the input, why “Filesystem state can change after is_junction returns.” should remain invariant and what observation would expose treating a check as a permanent security guarantee.

Reasoned route. Begin with “Filesystem state can change after is_junction returns.” Apply this procedure: Keep learning examples single-process and minimise the gap before a related safe action. For the science-data archive, introduce one controlled variation that exposes treating a check as a permanent security guarantee. The Boolean describes the observed moment, not an unchangeable future path. A complete answer explains why the near-miss fails, names the evidence that distinguishes it from the corrected case and transfers the rule without relying on the original variable names.

Case 4: backup verification task. Explain “Repeated classification is not a frozen guarantee” with source directories, mounted destinations and privacy-safe diagnostics. Before touching a tool, state which part of the case corresponds to the input, why “Filesystem state can change after is_junction returns.” should remain invariant and what observation would expose treating a check as a permanent security guarantee.

Reasoned route. Begin with “Filesystem state can change after is_junction returns.” Apply this procedure: Keep learning examples single-process and minimise the gap before a related safe action. For the backup verification task, introduce one controlled variation that exposes treating a check as a permanent security guarantee. The Boolean describes the observed moment, not an unchangeable future path. A complete answer explains why the near-miss fails, names the evidence that distinguishes it from the corrected case and transfers the rule without relying on the original variable names.

Diagnostic route

  • Model check: draw or list the exact values, objects, paths, characters or repository states before the operation.
  • Boundary check: construct the smallest safe input that reveals treating a check as a permanent security guarantee.
  • Evidence check: distinguish a displayed result from ownership, caching, consumption, font behaviour or object type.
  • Repair check: Keep learning examples single-process and minimise the gap before a related safe action.
  • Transfer check: repeat the rule in a second context and name what remains unchanged.

A parent does not need to memorise Python pathlib.Path.is_junction to support “Repeated classification is not a frozen guarantee”. Useful prompts are: “What did you expect?”, “Which state changed first?”, “What evidence tests Filesystem state can change after is_junction returns.?”, and “Can you make a smaller example of treating a check as a permanent security guarantee?” These questions keep ownership with the learner while making the reasoning visible.

Practice with an explained answer

Task. Describe a retargeting race conceptually. Write the prediction before running anything. Include one ordinary case and one boundary case, then explain the difference in two causal sentences.

Answer route. The earlier observation cannot prove the later state. The final output alone earns only partial credit. A strong answer connects it to “Filesystem state can change after is_junction returns.”, shows the relevant intermediate evidence and states why treating a check as a permanent security guarantee would lead to a different conclusion.

Decision and transfer

Use stronger platform primitives for high-stakes guarantees. Prefer the choice whose semantics and failure modes are easiest to explain for the actual job. Shorter syntax is useful only when it preserves that clarity.

Mastery of “Repeated classification is not a frozen guarantee” means the learner can predict the ordinary case, recognise treating a check as a permanent security guarantee, diagnose the earliest mistaken assumption, recover with “Keep learning examples single-process and minimise the gap before a related safe action.” and defend this decision: Use stronger platform primitives for high-stakes guarantees. Once that causal chain is stable, continue to the next chapter rather than adding repetitions of the same surface exercise.

Previous section · Contents · Next section

CHAPTER 20 OF 20 · Transfer with judgment

20. Choose the path predicate by reader job

Back to contents

is_junction, is_symlink, is_mount, is_dir and exists each answer a different question. That is the invariant to preserve when names, data or surrounding project details change.

Accurate tools keep neighbouring concepts separate. The useful question is not “Which line should I copy?” but “Which state, value or rendering decision does this operation control?” Answering that question prevents a correct-looking result from hiding a wrong mental model.

The most revealing near-miss is using one predicate as a universal path classifier. A learner should predict the result first, run the smallest safe case, label the observation and explain the earliest point where the prediction diverges. This turns an error into evidence rather than a verdict on ability.

Core worked example

checks={'junction':p.is_junction(),'symlink':p.is_symlink(),'mount':p.is_mount(),'dir':p.is_dir()}

Explained result. The result map preserves distinct evidence instead of collapsing all categories into one folder flag. The explanation should identify the input, the governing rule, the observable outcome and one boundary that would change the conclusion. If any of those four parts is missing, reduce the example and trace it again.

Read the trace, not just the last line

Trace reader job to documented predicate and boundary. Write the trace as a sequence of labelled states. For Python pathlib.Path.is_junction, inspect resolved pathnames, stat identities, exception types and before-and-after directory listings; a single final value can hide the mechanism that produced it.

For “Choose the path predicate by reader job”, separate contract from coincidence. The contract is “is_junction, is_symlink, is_mount, is_dir and exists each answer a different question.” and comes from the primary specification or manual. Coincidence is what happened on one machine, font, filesystem or repository. Record both, then use “State the policy question before selecting predicates.” to decide whether another observation challenges the model or merely reflects the environment.

Four purposeful transfer cases

Case 1: homework export guard. Model “Choose the path predicate by reader job” with an input document, two path spellings and a proposed output. Before touching a tool, state which part of the case corresponds to the input, why “is_junction, is_symlink, is_mount, is_dir and exists each answer a different question.” should remain invariant and what observation would expose using one predicate as a universal path classifier.

Reasoned route. Begin with “is_junction, is_symlink, is_mount, is_dir and exists each answer a different question.” Apply this procedure: State the policy question before selecting predicates. For the homework export guard, introduce one controlled variation that exposes using one predicate as a universal path classifier. The result map preserves distinct evidence instead of collapsing all categories into one folder flag. A complete answer explains why the near-miss fails, names the evidence that distinguishes it from the corrected case and transfers the rule without relying on the original variable names.

Case 2: photo-library alias check. Contrast “Choose the path predicate by reader job” with original files, hard-link aliases and independent copies. Before touching a tool, state which part of the case corresponds to the input, why “is_junction, is_symlink, is_mount, is_dir and exists each answer a different question.” should remain invariant and what observation would expose using one predicate as a universal path classifier.

Reasoned route. Begin with “is_junction, is_symlink, is_mount, is_dir and exists each answer a different question.” Apply this procedure: State the policy question before selecting predicates. For the photo-library alias check, introduce one controlled variation that exposes using one predicate as a universal path classifier. The result map preserves distinct evidence instead of collapsing all categories into one folder flag. A complete answer explains why the near-miss fails, names the evidence that distinguishes it from the corrected case and transfers the rule without relying on the original variable names.

Case 3: science-data archive. Stress-test “Choose the path predicate by reader job” with raw readings, a symlinked working folder and a missing target. Before touching a tool, state which part of the case corresponds to the input, why “is_junction, is_symlink, is_mount, is_dir and exists each answer a different question.” should remain invariant and what observation would expose using one predicate as a universal path classifier.

Reasoned route. Begin with “is_junction, is_symlink, is_mount, is_dir and exists each answer a different question.” Apply this procedure: State the policy question before selecting predicates. For the science-data archive, introduce one controlled variation that exposes using one predicate as a universal path classifier. The result map preserves distinct evidence instead of collapsing all categories into one folder flag. A complete answer explains why the near-miss fails, names the evidence that distinguishes it from the corrected case and transfers the rule without relying on the original variable names.

Case 4: backup verification task. Explain “Choose the path predicate by reader job” with source directories, mounted destinations and privacy-safe diagnostics. Before touching a tool, state which part of the case corresponds to the input, why “is_junction, is_symlink, is_mount, is_dir and exists each answer a different question.” should remain invariant and what observation would expose using one predicate as a universal path classifier.

Reasoned route. Begin with “is_junction, is_symlink, is_mount, is_dir and exists each answer a different question.” Apply this procedure: State the policy question before selecting predicates. For the backup verification task, introduce one controlled variation that exposes using one predicate as a universal path classifier. The result map preserves distinct evidence instead of collapsing all categories into one folder flag. A complete answer explains why the near-miss fails, names the evidence that distinguishes it from the corrected case and transfers the rule without relying on the original variable names.

Diagnostic route

  • Model check: draw or list the exact values, objects, paths, characters or repository states before the operation.
  • Boundary check: construct the smallest safe input that reveals using one predicate as a universal path classifier.
  • Evidence check: distinguish a displayed result from ownership, caching, consumption, font behaviour or object type.
  • Repair check: State the policy question before selecting predicates.
  • Transfer check: repeat the rule in a second context and name what remains unchanged.

A parent does not need to memorise Python pathlib.Path.is_junction to support “Choose the path predicate by reader job”. Useful prompts are: “What did you expect?”, “Which state changed first?”, “What evidence tests is_junction, is_symlink, is_mount, is_dir and exists each answer a different question.?”, and “Can you make a smaller example of using one predicate as a universal path classifier?” These questions keep ownership with the learner while making the reasoning visible.

Practice with an explained answer

Task. Choose predicates for a traversal boundary report. Write the prediction before running anything. Include one ordinary case and one boundary case, then explain the difference in two causal sentences.

Answer route. Use only the facts needed, while keeping missing and unsupported cases explicit. The final output alone earns only partial credit. A strong answer connects it to “is_junction, is_symlink, is_mount, is_dir and exists each answer a different question.”, shows the relevant intermediate evidence and states why using one predicate as a universal path classifier would lead to a different conclusion.

Decision and transfer

Prefer the narrowest documented classifier that proves the needed fact. Prefer the choice whose semantics and failure modes are easiest to explain for the actual job. Shorter syntax is useful only when it preserves that clarity.

Mastery of “Choose the path predicate by reader job” means the learner can predict the ordinary case, recognise using one predicate as a universal path classifier, diagnose the earliest mistaken assumption, recover with “State the policy question before selecting predicates.” and defend this decision: Prefer the narrowest documented classifier that proves the needed fact. Once that causal chain is stable, continue to the next chapter rather than adding repetitions of the same surface exercise.

Previous section · Contents · Next section

Parent guide: choose the next useful step

For Python pathlib.Path.is_junction, start with evidence rather than a label such as careless. Ask for one prediction and one trace. If the first transition is wrong, rebuild the model. If the model is sound but reference use is weak, practise finding the governing contract. If routine cases work but boundaries fail, vary one condition. If explanations transfer, move to a small project.

Punggol family routines are often busy, so use one complete Python pathlib.Path.is_junction prediction–observation–explanation cycle while attention is good. Ten to twenty focused minutes can be enough. Keep a four-line record: concept, prediction, observed difference and next test. Stop when fatigue replaces reasoning.

Use disposable fixtures, temporary directories and test repositories. Backups remain necessary. The activities in this guide are proposed home-learning exercises, not advertised lesson times, branch facilities, school affiliations or outcome guarantees.

Capstone practice with explained routes

1. Classify three paths

Compare an ordinary directory, file and controlled junction. Include an ordinary case, a boundary, a deliberate failure and a recovery. Write the expected state before each operation.

Explained route. Start with: Path.is_junction asks whether the concrete path points to a Windows junction, not whether it merely names a directory. Apply: Create one ordinary directory and one junction in a disposable Windows workspace. Verify: The result is True only when the path is a junction on a supporting Windows system. Then connect the result to platform support in Chapter 3. A complete solution contains the input model, a trace, observed evidence, a correction and one transfer statement.

2. Set a version floor

Record the Python version and feature availability. Include an ordinary case, a boundary, a deliberate failure and a recovery. Write the expected state before each operation.

Explained route. Start with: Path.is_junction is part of pathlib from Python 3.12 onward. Apply: Record the interpreter version and feature presence before running path fixtures. Verify: A supporting runtime exposes the method; older runtimes do not. Then connect the result to CI gating in Chapter 17. A complete solution contains the input model, a trace, observed evidence, a correction and one transfer statement.

3. Separate neighbouring predicates

Build a junction, symlink, mount and directory table. Include an ordinary case, a boundary, a deliberate failure and a recovery. Write the expected state before each operation.

Explained route. Start with: Path.is_junction and Path.is_symlink ask different filesystem questions. Apply: Create separate documented fixtures rather than renaming one mechanism. Verify: A fixture can be classified by the predicate matching its actual mechanism. Then connect the result to final predicate choice in Chapter 20. A complete solution contains the input model, a trace, observed evidence, a correction and one transfer statement.

4. Fence a directory walk

Stop or log before crossing a junction. Include an ordinary case, a boundary, a deliberate failure and a recovery. Write the expected state before each operation.

Explained route. Start with: A directory walker can cross a junction into another tree unless the application deliberately fences traversal. Apply: Use a shallow disposable tree and record every proposed descent before acting. Verify: The classifier can support a stop, log or allow decision before descent. Then connect the result to backup policy in Chapter 15. A complete solution contains the input model, a trace, observed evidence, a correction and one transfer statement.

5. Write a deletion preview

Report the boundary without mutating anything. Include an ordinary case, a boundary, a deliberate failure and a recovery. Write the expected state before each operation.

Explained route. Start with: A junction classification can trigger a review before a recursive delete chooses its scope. Apply: Perform only dry-run listing in the learning fixture. Verify: The guard prevents the example from treating the entry as an ordinary owned subtree. Then connect the result to time sensitivity in Chapter 19. A complete solution contains the input model, a trace, observed evidence, a correction and one transfer statement.

6. Design Windows integration coverage

Separate mocks, portable negatives and Windows positives. Include an ordinary case, a boundary, a deliberate failure and a recovery. Write the expected state before each operation.

Explained route. Start with: A positive junction fixture cannot be validated on a platform that does not support Windows junctions. Apply: Separate pure decision tests from Windows integration tests. Verify: The test suite records why the positive case is skipped rather than claiming portable success. Then connect the result to version diagnostics in Chapter 18. A complete solution contains the input model, a trace, observed evidence, a correction and one transfer statement.

7. Protect private paths

Create a useful report with synthetic labels. Include an ordinary case, a boundary, a deliberate failure and a recovery. Write the expected state before each operation.

Explained route. Start with: A useful report records Python version, operating system and the safely labelled path role. Apply: Use synthetic labels and redacted roots. Verify: The report makes an unavailable API or unsupported platform easier to distinguish from a negative path result. Then connect the result to relative-path context in Chapter 10. A complete solution contains the input model, a trace, observed evidence, a correction and one transfer statement.

8. Choose the correct classifier

Defend one predicate set for four path-management jobs. Include an ordinary case, a boundary, a deliberate failure and a recovery. Write the expected state before each operation.

Explained route. Start with: is_junction, is_symlink, is_mount, is_dir and exists each answer a different question. Apply: State the policy question before selecting predicates. Verify: The result map preserves distinct evidence instead of collapsing all categories into one folder flag. Then connect the result to the core junction model in Chapter 1. A complete solution contains the input model, a trace, observed evidence, a correction and one transfer statement.

Frequently asked questions

How long should a practice session be?

Use one complete Python pathlib.Path.is_junction prediction–observation–explanation cycle while attention remains good. Ten to twenty focused minutes can be enough.

Should every option or method be memorised?

No. For Python pathlib.Path.is_junction, memorise governing distinctions and practise retrieving the primary reference. Understanding means predicting and explaining, not reciting a parameter list.

What if the result is correct but the explanation is weak?

Treat it as partial success. Ask for a trace and change one boundary. A reliable model survives controlled variation.

Is the shortest solution the best?

Not automatically. Prefer the solution whose semantics, failure modes and maintenance cost are easiest to justify for the actual project.

When should the official reference be used?

Use it whenever Python pathlib.Path.is_junction syntax, supported values, version behaviour or implementation boundaries matter. The primary source settles the current contract.

How can a parent help without technical expertise?

Ask what was predicted, where the first difference appeared, what evidence matters and which smaller example could isolate it.

How do we test transfer?

Change the context, vocabulary and one boundary. Require the learner to identify the invariant before using a tool.

What should be saved after practice?

Keep the corrected rule, one trace, one boundary case and the next question. Avoid storing pages of unexplained output.

Can these exercises replace backups?

No. Use disposable examples and proper backups. Learning should not endanger schoolwork, repositories or personal data.

What counts as mastery?

The learner can predict, verify, diagnose, recover and justify a choice across more than one context, while knowing when to consult the current reference.

Primary and supporting references

Return to contents

Continue from here: Start Here · Tuition · Education · Pathways · Parenting 101 · All Site Routes

eduKate Punggol

Contact

83 Punggol Central, Singapore 828761

edu|Kate Bukit Timah

8 Fourth Avenue, Singapore 268674

By Appointment +65 8823 1234
admin@edukatesg.com

Email Us

When a child finally understands, school becomes less frightening and the future opens wider. Email us for the latest schedules and fees.

← 返回

感谢您的回复。 ✨

了解 eduKate Punggol 的更多信息

立即订阅以继续阅读并访问完整档案。

继续阅读