๐ŸŽ 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

Asyncio
A Python library for writing concurrent code using async/await syntax for non-blocking I/O operations.
Python Metaclass
A class whose instances are classes themselves - the class of a class that controls how classes are created and behaved.
List Comprehension
A concise syntax for creating new lists by applying an expression to each item in an existing iterable.
Pathlib
A modern Python module providing an object-oriented interface for filesystem paths, replacing os.path operations.
Pickle
Python's built-in module for serializing and deserializing Python objects into a byte stream for storage or transmission.
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 โ†’