On this page
enum.verify
Prev: enum.unique | Up: enum
Rel: enum.auto, enum.Enum, enum.EnumCheck, enum.EnumDict
Ref: docs.python.org — enum.verify
Tags: #public #python3 #stdlib #enum
Import
import enum
from enum import verify
Signature & Overview
enum.verify(*checks)
Check an enumeration for various constraints. (see EnumCheck)
Usage
from enum import CONTINUOUS, UNIQUE, Enum, verify
@verify(UNIQUE, CONTINUOUS)
class Priority(Enum):
LOW = 1
MED = 2
HIGH = 3
assert len(Priority) == 3
Gotchas
- Python 3.11+ generalized validator: Supports
UNIQUE,CONTINUOUS(no integer gaps), andNAMED_FLAGS(all composite flags backed by named single-bit flags).
REPL Inspect
from enum import verify
help(verify)
Linked from
Related notes
- tuts/python3/stdlib_module/enum/unique Linked here; links to this page; shared tags: #enum, #stdlib
- tuts/python3/stdlib_module/enum/auto Linked here; shared tags: #enum, #stdlib
- tuts/python3/stdlib_module/enum/Enum Linked here; shared tags: #enum, #stdlib
- tuts/python3/stdlib_module/enum/EnumCheck Linked here; shared tags: #enum, #stdlib
- tuts/python3/stdlib_module/enum/EnumDict Linked here; shared tags: #enum, #stdlib
- tuts/python3/stdlib_module/enum links to this page; shared tags: #stdlib
- tuts/python3/stdlib_module/enum/EnumMeta shared tags: #enum, #stdlib
- tuts/python3/stdlib_module/enum/EnumType shared tags: #enum, #stdlib
- tuts/python3/stdlib_module/enum/Flag shared tags: #enum, #stdlib
- tuts/python3/stdlib_module/enum/FlagBoundary shared tags: #enum, #stdlib