Python 3.13+enumterm
enum.EnumDict
metaclass
The special namespace dict used while creating an enum; tracks order and forbids duplicate members (public in 3.13+).
Syntax
ns = enum.EnumDict()
Everyday code never touches this class; it exists so that assigning the same name twice inside an enum body fails with TypeError immediately instead of silently redefining a member. You only reach for it when writing your own EnumType subclass and preparing the namespace by hand. Before 3.13 the same object existed as the private _EnumDict, so version-tolerant code has to check that the public name is there.
Examples
import enum
d = enum.EnumDict() if hasattr(enum, 'EnumDict') else {}
d['A'] = 1
print(d['A']) # → 1
See also
Open in the full glossarydocs.python.orgReport an inaccuracy