I have an Enum in Python that looks something like this:
import enum class Color(enum.Enum): red = 'red' blue = 'blue' yellow = 'yellow' puce = 'puce' chartreuse = 'chartreuse'
And I want to have something like:
primary_colors = (Color.red, Color.blue, Color.yellow)
But naturally if I try and stick that line in the enum,
Color is not defined. And if I use
(red, blue, yellow) then it becomes just a tuple of strings. And I can't extend Enum, so I can't do something like:
class PrimaryColor(enum.Enum): red = 'red' yellow = 'yellow' green = 'green' class Color(enum.Enum, PrimaryColor): puce = 'puce' chartreuse = 'chartreuse'
So what's an idiomatic sort of way that I can say that I have this collection of primary colors that's a subset of
Color? Am I limited to something like this?
primary_colors = (Color.red, Color.yellow, Color.blue)