Skip to content

Instantly share code, notes, and snippets.

@pythonhacker
Created March 11, 2026 17:27
Show Gist options
  • Select an option

  • Save pythonhacker/2ce96de2ffb4fe237680b6a82235ab69 to your computer and use it in GitHub Desktop.

Select an option

Save pythonhacker/2ce96de2ffb4fe237680b6a82235ab69 to your computer and use it in GitHub Desktop.
from dataclasses import dataclass
@dataclass(frozen=True)
class ColorData:
r: int = 0
g: int = 0
b: int = 0
def __post_init__(self):
for v in (self.r, self.g, self.b):
if not 0 <= v <= 255:
raise ValueError("RGB must be 0..255")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment