Python Design and Type Hints
Keep Each Report's Notes Separate
BOTIE
Examples, experiments and workspace controls
Connect a tool's inputs to see what it produces. You can try a branch before connecting it to Result.
Try your own inputs
Use a copy of the example to try your own data. Keep the problem's assumptions in mind, and predict the effect of a change before checking the output. You can also add another branch to compare two ways of doing the calculation.
Context for this challenge
Create a report for each greenhouse, then add the supplied note to the named greenhouse only. Return rows containing house and tags. Other greenhouses must keep empty notes lists.
Botie is adding notes to greenhouse reports. An empty notes list can be a new object for each report or the same object reused by several reports.
Create the notes lists has a choice between reusing one list and creating a new list for each report. Attach notes to their reports pairs those lists with greenhouse names. Add a note to one greenhouse then updates the named report. With only north in the first example, try either list choice and inspect the result.
Examples and results
- Greenhouses needing reports
- 0north
- Greenhouse receiving the note
north
- Note to add
checked
- Required result
- house
- north
- tags
- ["checked"]
house tags north ["checked"]
- Greenhouses needing reports
- 0lab
- Greenhouse receiving the note
lab
- Note to add
review
- Required result
- house
- lab
- tags
- ["review"]
house tags lab ["review"]
Try a fresh construction
This clears this draft, including its undo history. Earlier successful attempts stay recorded. Build again without opening hints to record an independent attempt.
Stuck? Inspect a worked construction
The tools below form one possible solution. You can assemble it, follow its signals, and undo that change to return to your own construction.
Assumptions and test precision
The records illustrate the ownership of mutable defaults; they are not Python dataclass instances and do not validate Python annotations. Each run uses a private copy so repeated tests leave the source data unchanged. Numerical tests allow a difference of 0.001. Lists and structures must also have the right shape.
The Middle Report Receives the Note
This check uses the pieces from “Create Reports and Add One Note”.
BOTIE
- Greenhouses needing reports
- 0east
- 1west
- 2roof
- Greenhouse receiving the note
west
- Note to add
recalibrated
Saving your prediction runs your current construction on these inputs and checks the earlier examples too.
Build a construction in the workspace above first. This case will test those pieces.
Why did the one-report example fail to expose the shared-list mistake?
Test changes to one object while another object exists. Equal initial values do not establish independent ownership.
The records illustrate the ownership of mutable defaults; they are not Python dataclass instances and do not validate Python annotations. Each run uses a private copy so repeated tests leave the source data unchanged.