ID EN
Enum

UNIQUE

Python 3.11

Ensure that each value has only one name:

Syntax

PYTHON
UNIQUE

Examples

Example 1
PYTHON
>>> from enum import Enum, verify, UNIQUE
>>> @verify(UNIQUE)
... class Color(Enum):
...     RED = 1
...     GREEN = 2
...     BLUE = 3
...     CRIMSON = 1
Traceback (most recent call last):
...
ValueError: aliases found in <enum 'Color'>: CRIMSON -> RED