On this page
enum.EnumDict
Prev: enum.EnumCheck | Up: enum | Next: enum.EnumMeta
Rel: enum.auto, enum.Enum, enum.EnumCheck, enum.EnumMeta
Ref: docs.python.org — enum.EnumDict
Tags: #public #python3 #stdlib #enum
Import
import enum
from enum import EnumDict
Signature & Overview
enum.EnumDict(cls_name=None)
Track enum member order and ensure member names are not reused.
Methods & Attributes
EnumDict.clear(self, /)— Remove all items from the dict.EnumDict.copy(self, /)— Return a shallow copy of the dict.EnumDict.fromkeys(iterable, value=None, /)— Create a new dictionary with keys from iterable and values set to value.EnumDict.get(self, key, default=None, /)— Return the value for key if key is in the dictionary, else default.EnumDict.items(self, /)— Return a set-like object providing a view on the dict's items.EnumDict.keys(self, /)— Return a set-like object providing a view on the dict's keys.EnumDict.pop(...)— If the key is not found, return the default if given; otherwise, raise a KeyError.EnumDict.popitem(self, /)— Remove and return a (key, value) pair as a 2-tuple.EnumDict.setdefault(self, key, default=None, /)— Insert key with a value of default if key is not in the dictionary.EnumDict.update(self, members, **more_members)—EnumDict.updatemethod/property.EnumDict.values(self, /)— Return an object providing a view on the dict's values.
Usage
from enum import EnumDict
# Internal mapping used by EnumType.__prepare__ to track member names and _ignore_
d = EnumDict()
d["RED"] = 1
assert "RED" in d._member_names
Gotchas
- Metaclass implementation detail: Rarely instantiated directly unless you are writing a custom
EnumTypesubclass.
REPL Inspect
from enum import EnumDict
help(EnumDict)
Linked from
- tuts/python3/stdlib_module/enum
- tuts/python3/stdlib_module/enum/auto
- tuts/python3/stdlib_module/enum/Enum
- tuts/python3/stdlib_module/enum/EnumCheck
- tuts/python3/stdlib_module/enum/EnumMeta
- tuts/python3/stdlib_module/enum/EnumType
- tuts/python3/stdlib_module/enum/Flag
- tuts/python3/stdlib_module/enum/FlagBoundary
- tuts/python3/stdlib_module/enum/global_enum
- tuts/python3/stdlib_module/enum/global_enum_repr
- tuts/python3/stdlib_module/enum/global_flag_repr
- tuts/python3/stdlib_module/enum/global_str
- tuts/python3/stdlib_module/enum/IntEnum
- tuts/python3/stdlib_module/enum/IntFlag
- tuts/python3/stdlib_module/enum/member
- tuts/python3/stdlib_module/enum/nonmember
- tuts/python3/stdlib_module/enum/pickle_by_enum_name
- tuts/python3/stdlib_module/enum/pickle_by_global_name
- tuts/python3/stdlib_module/enum/property
- tuts/python3/stdlib_module/enum/ReprEnum
- tuts/python3/stdlib_module/enum/StrEnum
- tuts/python3/stdlib_module/enum/unique
- tuts/python3/stdlib_module/enum/verify
Related notes
- tuts/python3/stdlib_module/enum/auto Linked here; links to this page; shared tags: #enum, #stdlib
- tuts/python3/stdlib_module/enum/Enum Linked here; links to this page; shared tags: #enum, #stdlib
- tuts/python3/stdlib_module/enum/EnumCheck Linked here; links to this page; shared tags: #enum, #stdlib
- tuts/python3/stdlib_module/enum/EnumMeta Linked here; links to this page; shared tags: #enum, #stdlib
- tuts/python3/stdlib_module/enum/EnumType links to this page; shared tags: #enum, #stdlib
- tuts/python3/stdlib_module/enum/Flag links to this page; shared tags: #enum, #stdlib
- tuts/python3/stdlib_module/enum/FlagBoundary links to this page; shared tags: #enum, #stdlib
- tuts/python3/stdlib_module/enum/global_enum links to this page; shared tags: #enum, #stdlib
- tuts/python3/stdlib_module/enum/global_enum_repr links to this page; shared tags: #enum, #stdlib
- tuts/python3/stdlib_module/enum/global_flag_repr links to this page; shared tags: #enum, #stdlib