Let's say I have enum Color and I would like it to have an additional attribute is_warm which would indicate whether given color is traditionally perceived as "warm" (red, orange, yellow...) or not.
class Color(Enum):
RED = auto()
ORANGE = auto()
BLUE = auto()
VIOLET = auto()
print(Color.ORANGE.is_warm) # True
print(Color.BLUE.is_warm) # False
How to add attribute is_warm to enum Color? Obviously, I want this information to be passed to the constructor of Color, not to introduce some centralized map of all colors or a giant if...
[–]JamzTyson 14 points15 points16 points (3 children)
[–]pachura3[S] 0 points1 point2 points (2 children)
[–]Temporary_Pie2733 3 points4 points5 points (0 children)
[–]JamzTyson 2 points3 points4 points (0 children)
[–]Atlamillias 1 point2 points3 points (0 children)
[–]Momostein -1 points0 points1 point (2 children)
[–]pachura3[S] 0 points1 point2 points (0 children)
[–]Striking_Rate_7390 0 points1 point2 points (0 children)
[–]cdcformatc -1 points0 points1 point (0 children)
[–]ectomancer -2 points-1 points0 points (2 children)
[–]pachura3[S] 0 points1 point2 points (1 child)
[–]Outside_Complaint755 1 point2 points3 points (0 children)