Lesson map
Lesson 05. Map, example, EX051.
flowchart TD
T["Eight triples"] --> F["setting not in the allowed set"]
T --> N["count of True flags"]
F --> B["three names, list order"]
N --> S["sensitive 5"]
B --> Q{"Is the filter a later census?"}
S --> Q
Q -->|No| K["Keep the embedded print"]
One list. One membership test. Three printed numbers.
Logical drawing
items 8, sensitive 5, shared too widely 3
patient-letters/: anyone-with-link
invoices/: anyone-with-link
old-backup.zip: anyone-with-link
Learning outcomes
After this chapter, you should be able to:
- Name the three reductions the sharing script actually computes.
- Keep list order distinct from the April incident.
- Refuse a note that replaces this export with a later folder state.
5.1 Three reductions, and no walk inside a folder.
lab_sharing.py stores eight triples. Each triple is a name, a setting string, and a Boolean. The names are the top-level storage items only. A file inside patient-letters/ is not a fourth field and cannot change len(items).
The Boolean sum is sum(1 for i in items if i[2]). Python counts True as one, so the five sensitive flags print as sensitive 5. That sum does not look at the setting string. referrals/ and booking-app-config contribute to the five and do not contribute to the failure list.
The failure list is a comprehension: keep the pair when the setting is absent from allowed[sens]. allowed[True] holds staff and admins. allowed[False] holds those two strings plus public. The comprehension does not sort. patient-letters/ is printed first because it is the first failing triple, not because a patient mentioned it. rota.xlsx, price-list.pdf, logo.png, referrals/, and booking-app-config are tested and kept out of bad.
A later staff-only change is a decision-log sentence. It is not a fourth run, and it does not edit these eight triples. Printing shared too widely 2 would require deleting a triple this file still contains.
5.2 Worked example
Lesson table; scroll horizontally to read all columns →
| Offered result | What produced it | Decision |
|---|---|---|
items 8, sensitive 5, shared too widely 3 |
Length, Boolean sum, filter length | Keep |
| The three names in list order | The comprehension, unsorted | Keep |
| "The script now omits patient-letters." | No edit of the eight triples | Refuse |
| "The filter counted files inside the folders." | The list has no child rows | Refuse |
Synthetic case. The eight triples are the only sharing output.
Errors and limits
Directory children stay uncounted. Do not repair the export so that it matches the afternoon change.
Apply
- EX051 — One filter. The print says 8 items, 5 sensitive, and 3 shared too widely, then names patient-letters, invoices, and old-backup.zip. May a later staff-only change, or a count of files inside those folders, replace that print?
Show marking criteria
Rubric: 3 = no; the eight triples stay; the Boolean sum stays 5; the filter stays 3, in list order; do not edit the script;; 2 = the print stays and the later change stays prose;; 1 = one number;; 0 = none.