Skip to content

Instantly share code, notes, and snippets.

@bryanmylee
Created December 13, 2021 19:28
Show Gist options
  • Save bryanmylee/883b74067cb6701b113186c001bf72d4 to your computer and use it in GitHub Desktop.
Save bryanmylee/883b74067cb6701b113186c001bf72d4 to your computer and use it in GitHub Desktop.
Using `field` to customize field properties
from dataclasses import dataclass, field
from typing import FrozenSet
@dataclass(frozen=True, eq=True)
class Ingredient:
id: str
g_per_ml: float
substitution_ids: FrozenSet[str] = field(
default_factory=lambda: frozenset(), compare=False
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment