🎁 New User? Get 20% off your first purchase with code NEWUSER20 Register Now →
Menu

Categories

Python Beginner

What is Enum?

A built-in class for creating enumerated constants — named groups of related values that improve code readability.

Enums replace magic numbers and strings with meaningful names: class Color(Enum): RED = 1; GREEN = 2; BLUE = 3. Access via Color.RED, Color(1), or Color['RED']. Members are iterable and comparable.

Specialized enums include IntEnum (integer-compatible), StrEnum (Python 3.11+, string-compatible), Flag (combinable with bitwise operators), and auto() for automatic value assignment. Enums make code more readable and prevent invalid values.

Related Terms

Uvicorn
A lightning-fast ASGI server for Python, commonly used to serve FastAPI and other async web applications.
Python Typing Module
A standard library module providing type hints for function signatures and variables, enabling static analysis without runtime enforcement.
Walrus Operator
The := operator that assigns a value to a variable as part of an expression, introduced in Python 3.8.
Python Wheel
A built distribution format (.whl) that allows faster installation of Python packages by avoiding the need for compilation.
Pickle
Python's built-in module for serializing and deserializing Python objects into a byte stream for storage or transmission.
Docstring
A string literal placed as the first statement in a module, class, or function to document its purpose and usage.
View All Python Terms →