🎁 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

Python Wheel
A built distribution format (.whl) that allows faster installation of Python packages by avoiding the need for compilation.
Python Interpreter
The program that reads and executes Python code, translating it into machine instructions at runtime.
Pip Requirements File
A text file listing Python package dependencies with version specifications for reproducible project installations.
Python ABC Module
The Abstract Base Classes module that enables defining interfaces and abstract methods that subclasses must implement.
Django
A high-level web framework that follows the batteries-included philosophy, providing ORM, admin, auth, and more out of the box.
Dictionary
A built-in data structure that stores key-value pairs with O(1) average lookup time using hash tables.
View All Python Terms →