🎁 New User? Get 20% off your first purchase with code NEWUSER20 · ⚡ Instant download · 🔒 Secure checkout 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

FastAPI
A modern, high-performance Python web framework for building APIs with automatic OpenAPI documentation and type validation.
Pip Requirements File
A text file listing Python package dependencies with version specifications for reproducible project installations.
Python Metaclass
A class whose instances are classes themselves — the class of a class that controls how classes are created and behaved.
Python Wheel
A built distribution format (.whl) that allows faster installation of Python packages by avoiding the need for compilation.
Context Manager
An object that manages resources by defining setup and cleanup actions using the with statement.
GIL (Global Interpreter Lock)
A mutex in CPython that allows only one thread to execute Python bytecode at a time, limiting true parallelism.
View All Python Terms →