🎁 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

Poetry
A modern Python dependency management and packaging tool that handles virtual environments, locking, and publishing.
Type Hints
Optional annotations that indicate the expected types of variables, function parameters, and return values.
Walrus Operator
The := operator that assigns a value to a variable as part of an expression, introduced in Python 3.8.
Scikit-learn
The most popular Python machine learning library providing simple and efficient tools for data analysis and modeling.
Dataclass
A decorator that automatically generates __init__, __repr__, __eq__, and other special methods for classes that mainly store data.
Magic Methods
Special double-underscore methods that define how Python objects behave with built-in operations and functions.
View All Python Terms →