Using a Flask blueprint

Before defining the blueprint, we'll define some classes and functions that establish the problem domain. We'll define an enumeration of the Status values, with "Updated" and "Created" as the only two values. We'll define a set of dice using a dataclass named Dice. This class includes the current state of the dice, a unique identifier for this particular collection of dice, and an overall status to show whether it was initially created or has been updated. Separate from the class, it's helpful to have a make_dice() function to create a Dice instance.

For this example, here are the definitions:

from typing import Dict, Any, Tuple, Listfrom dataclasses import dataclass, asdictimport randomimport secretsfrom enum import ...

Get Mastering Object-Oriented Python - Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.