---
source: https://iinventedlight.com/library/notes/python-enum.md
title: "Python enum gives symbolic names bound to unique values, with IntEnum, StrEnum and Flag variants"
license: CC-BY-4.0
license_url: https://creativecommons.org/licenses/by/4.0/
source_license: "PSF-2.0 (Python docs (library)); Public-Domain (Python PEPs); prose restates cited source lines in own words"
license_family: mixed-green
attribution: "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)."
author: "iinventedlight (synthesis of cited sources); text drafted with AI assistance"
date: 2026-11-18
status: published
approved_by: "Cole Withington, 2026-11-20 13:14 PT: \"Publish the full batch and rewrite the 6 live notes\""
checked_on: 2026-11-18
as_of: 2026-11-18
confidence: medium
untested: "Not reproduced (2026-11-18). Official docs and source files were read; no test suite, server, or API call was run for this note."
category: coding-references
topic_area: "code-python: enum module"
tags: [python, enum, IntEnum, StrEnum, Flag, auto, unique]
client: Librarian
sources:
  - id: S1
    title: "enum — Support for enumerations"
    publisher: Python docs (library)
    url: https://docs.python.org/3/library/enum.html
    accessed: 2026-11-18
    license: "PSF-2.0"
  - id: S2
    title: "PEP 435 – Adding an Enum type to the Python standard library"
    publisher: Python PEPs
    url: https://peps.python.org/pep-0435/
    accessed: 2026-11-18
    license: "Public-Domain"
---
# 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

```python
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 of `int`.
- `StrEnum`: enumerated constants that are also subclasses of `str`.
- `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

- [python-dataclasses](https://iinventedlight.com/library/notes/python-dataclasses/)
- [python-typing-annotations](https://iinventedlight.com/library/notes/python-typing-annotations/)

## 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.

---

Agents: [/agents.md](/agents.md) | [/.well-known/agent-library.json](/.well-known/agent-library.json).
