Python Enum (Enumeration)
In computer programming, an enumerated type is a data type consisting of a set of named values called members. The names are must be unique. Enumeration is often called enum. In this Python tutorial section you will learn about Enum (Enumeration).
Objectives
-
Create and use of Enum
Create and use of Python Enum
Code
# Define Status Enum
from enum import Enum
class Status(Enum):
ACTIVE = "A"
INACTIVE = "I"
SUSPEND = "S"
CANCEL = "C"
# Access Status Enum
print(Status.ACTIVE)
Output
Status.ACTIVE
Process finished with exit code 0