PyDocs

Nav

Data Types

Enum._missing_

enum

classmethod of Enum · Added in 3.6 (source)
  • Enum._missing_(cls, value)
A classmethod for looking up values not found in cls. By default it does nothing, but can be overridden to implement custom search behavior:
1 Example
>>> from enum import auto, StrEnum
>>> class Build(StrEnum):
...     DEBUG = auto()
...     OPTIMIZED = auto()
...     @classmethod
...     def _missing_(cls, value):
...         value = value.lower()
...         for member in cls:
...             if member.value == value:
...                 return member
...         return None
...
>>> Build.DEBUG.value
'debug'
>>> Build('deBUG')
<Build.DEBUG: 'debug'>
from the Python docs
See Also
No see-alsos for enum/Enum._missing_
0 Notes
No notes for Enum._missing_