Review
Reconstruct the path from dot notation and documented calls to small classes, hints, records, configuration, and returned evidence.
Read Dot Notation from Left to Right
In value.name, Python selects the attribute name from value. In
value.method(), it first selects method and then calls it. The parentheses
change the operation. A dictionary lookup such as record["name"] is different:
the string is a key stored in the dictionary, not an attribute name written in
the program.
When attribute access fails, inspect the object and its type before changing
the attribute name. AttributeError is evidence that the selected object does
not provide that attribute.
Connect a Signature to One Call
A documented signature names the callable, its required parameters, optional parameters and defaults, and its return. Match each argument in the call to a parameter before relying on the result. A keyword argument makes that mapping explicit; an omitted optional argument uses its documented default.
Documentation describes the contract. A small call and type(result) provide
evidence about the actual value returned in the current case.
Keep Classes, Instances, and Aliases Distinct
A class defines how a kind of object is initialized and which methods it
provides. Calling the class constructs an instance. Inside an instance method,
self refers to the instance that received the call.
Two constructor calls create two instances with separate fields. Assigning a second name to one instance creates an alias; both names then observe changes to that same object.
Read Hints as Descriptions
In this boundary,
the parameter is expected to be a list containing floats or explicit None
markers. The function may return a float or None. These hints do not convert
an input, reject a runtime value, or describe an array's complete shape. The
function body still owns its runtime behavior and validation.
Use Records to Make Roles Visible
A dataclass can generate ordinary initialization, display, and equality for a
plain record whose fields are declared with hints. frozen=True blocks normal
field assignment; it does not recursively freeze every object stored in a
field and does not validate the field values automatically.
Configuration, input, and result answer different questions:
| Role | Example | Owner |
|---|---|---|
| configuration | unit and classification thresholds | the chosen run settings |
| input | the six measured values, including one None marker | the supplied data |
| result | accepted/rejected counts, mean, and class counts | the completed computation |
Pass configuration into the computation rather than hiding it in global state. Validate its relationship at the boundary, then return an explicit result record. Comparing two configurations should keep the input fixed so the changed settings remain visible.