Python 3.4+enumterm
enum.EnumMeta
metaclass
The former name of the enum metaclass — an alias of enum.EnumType kept for compatibility.
Syntax
enum.EnumMeta is enum.EnumType
The one practical use: type(Color) is the metaclass, so isinstance(X, EnumType) answers "is X an enum class?", whereas isinstance(X, Enum) tests a single member. The rename landed in 3.11; the old name still works and is not slated for removal, but new code should say EnumType.
Examples
# Python 3.11+
import enum
print(enum.EnumMeta is enum.EnumType) # → True
print(enum.EnumMeta.__name__) # → EnumType
import enum
class Color(enum.Enum): RED = 1; GREEN = 2
print(type(Color) is enum.EnumMeta) # → True
print(len(Color)) # → 2
print(list(Color)) # → [<Color.RED: 1>, <Color.GREEN: 2>]
See also
Open in the full glossarydocs.python.orgReport an inaccuracy