Review

Core idea

Objects and records help name related values.

Use them when structure improves clarity. Do not use them just to make code look more advanced.

Attributes

Read an attribute with dot notation:

config.learning_rate

If an attribute does not exist, Python raises AttributeError.

Small classes

A class can define how to build an object:

self is the object being initialized.

Methods

A method is a function attached to an object:

Call it with:

record.passed()

Dataclasses

Use dataclasses for simple records:

Python creates the basic initializer and a helpful printed representation.

Type hints

Function hints document expected inputs and return values:

Hints are not conversions and are not fully enforced by Python at runtime.

Configuration records

Use configuration records to name related settings:

Pass one clear object instead of several mysterious positional arguments.