Problem:
You want to inherit a Python class
from enum
like this:
import enum class MyEnum(enum): X = 1 Y = 2class
but when you try to run it, you see an error message like this:
Traceback (most recent call last): File "test.py", line 3, in <module> class MyEnum(enum): TypeError: Error when calling the metaclass bases module.__init__() takes at most 2 arguments (3 given)
Solution:
You are not trying to inherit from the Enum
class (capital E!) but from the enum
module!
This is the correct syntax:
from enum import Enum class MyEnum(Enum): X = 1 Y = 2