# Enums
# =====
# Key Features:
# - Enums are iterable: You can loop through an Enum class.
# - Unique values: Enum members are uniquel; two
# members cannot have the same value.
# - Immutable: Enum members are constants and cannot be modified.
from enum import Enum
class Color(Enum):
RED = 1
GREEN = 2
BLUE = 3
red = Color.RED
green = Color.GREEN
print(red == Color.RED)
print(red == green)
print(Color.RED.name)
print(Color.RED.value)
for color_enums in Color:
print(color_enums)
# Output:
True
False
RED
1
Color.RED
Color.GREEN
Color.BLUE
댓글 영역