is a set of symbolic names (members) bound to unique values
can be iterated over to return its canonical (i.e. non-alias) members in definition order
uses call syntax to return members by value
uses index syntax to return members by name
Enumerations are created either by using class syntax, or by using function-call syntax:
>>> from enum import Enum>>> # class syntax>>> class Color(Enum):... RED = 1... GREEN = 2... BLUE = 3>>> # functional syntax>>> Color = Enum('Color', [('RED', 1), ('GREEN', 2), ('BLUE', 3)])
Even though we can use class syntax to create Enums, Enums are not normal Python classes. See How are Enums different? for more details.
Note: Nomenclature
The class Color is an enumeration (or enum)
The attributes Color.RED, Color.GREEN, etc., are enumeration members (or members) and are functionally constants.
The enum members have names and values (the name of Color.RED is RED, the value of Color.BLUE is 3, etc.)