Python enum gives symbolic names bound to unique values, with IntEnum, StrEnum and Flag variants
Answer: An enumeration is a set of symbolic names (members) bound to unique values. The @unique Enum class decorator ensures only one name is bound to any one value.
Example
from enum import Enum, StrEnum, auto, unique
@unique
class Color(Enum):
RED = 1
GREEN = 2
class Mode(StrEnum):
STRICT = auto() # value "strict"
Base classes
Enum: base class for creating enumerated constants.IntEnum: enumerated constants that are also subclasses ofint.StrEnum: enumerated constants that are also subclasses ofstr.Flag: members can be combined with bitwise operators.
auto() and aliases
For StrEnum, auto() produces the member's name, lower-cased. Take care when mixing auto() with manually specified values. @unique is an Enum class decorator that ensures only one name is bound to any one value. Iterating over an enumeration returns its canonical (non-alias) members.
Background
PEP 435 proposed adding an enumeration type to the Python standard library.
See also
Claims
- id: C1 claim: An enumeration is a set of symbolic names bound to unique values. source: S1 evidence: "is a set of symbolic names (members) bound to unique values"
- id: C2 claim: IntEnum members are also subclasses of int. source: S1 evidence: "Base class for creating enumerated constants that are also subclasses of int"
- id: C3 claim: @unique ensures only one name per value. source: S1 evidence: "Enum class decorator that ensures only one name is bound to any one value"
- id: C4 claim: PEP 435 proposed an enumeration type for the standard library. source: S2 evidence: "This PEP proposes adding an enumeration type to the Python standard library."
Sources
- [S1] enum — Support for enumerations. Python docs (library). https://docs.python.org/3/library/enum.html . License: PSF-2.0. Accessed 2026-11-18.
- [S2] PEP 435 – Adding an Enum type to the Python standard library. Python PEPs. https://peps.python.org/pep-0435/ . License: Public-Domain. Accessed 2026-11-18.
License: this note is CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/). Summary by iinventedlight (AI-assisted). Sources: Python docs (library), enum — Support for enumerations; Python PEPs, PEP 435 – Adding an Enum type to the Python standard library. PSF-2.0 (https://docs.python.org/3/license.html). Copyright Python Software Foundation. Public-Domain (https://peps.python.org/pep-0001/). PEP text is placed in the public domain (some also CC0-1.0). Text was condensed and changed from the originals.
License: CC-BY-4.0 · Summary by iinventedlight (AI-assisted). Sources: Python docs (library), enum — Support for enumerations; Python PEPs, PEP 435 – Adding an Enum type to the Python standard library. PSF-2.0 (https://docs.python.org/3/license.html). Copyright Python Software Foundation. Public-Domain (https://peps.python.org/pep-0001/). PEP text is placed in the public domain (some also CC0-1.0).
Cite this
iinventedlight. 2026. "Python enum gives symbolic names bound to unique values, with IntEnum, StrEnum and Flag variants." iinventedlight Library, iil:note:qfr0y2wc, version of 2026-11-18. https://iinventedlight.com/library/notes/python-enum/. License: CC-BY-4.0.
@misc{iil_note_qfr0y2wc,
author = {{iinventedlight}},
title = {{Python enum gives symbolic names bound to unique values, with IntEnum, StrEnum and Flag variants}},
howpublished = {iinventedlight Library},
year = {2026},
date = {2026-11-18},
url = {https://iinventedlight.com/library/notes/python-enum/},
note = {Permanent ID iil:note:qfr0y2wc. License: CC-BY-4.0.},
}
Spotted a mistake? Use the MCP feedback tool or email hello@iinventedlight.com. Or Report a correction (no account needed).
Extra files beside this note
These files use this note's license, shown below. Paper extras retain their reproduction status; a link is not a reproduction.
- python-enum.table.json (table; CC-BY-4.0)
- python-enum.schema.json (schema; CC-BY-4.0)
For language models and agents: start at /llms.txt | /agents.md | /.well-known/agent-library.json. This page in Markdown: /library/notes/python-enum.md.