02 Intermediate Python: OOP, Types, Errors & Testing/2.14 Lab code (reference solutions)/2.14.3 lab/library/models.py
§ 2.14.3section 17 of 20·~4 min
lab/library/models.py
from dataclasses import dataclass, field
@dataclass
class Book:
isbn: str
title: str
author: str
issued_to: str | None = None
@property
def available(self) -> bool:
return self.issued_to is None
@dataclass
class Member:
member_id: str
name: str
borrowed: list[str] = field(default_factory=list)