Is it possible to define enums without values with Python?
One way is to use the Enum base class as a callable:
Color = Enum('Color', 'RED BLUE GREEN ORANGE')
If you're using Python 3.6 or later, you can use enum.auto()
:
from enum import Enum, auto
class Color(Enum):
RED = auto()
BLUE = auto()
The documentation for the enum
library describes this and other useful features like the @unique
decorator.