I'm trying to define an object-valued enum, and I'm running in an error of "missing 1 required positional argument" in enum_member.__init__(*args)
A basic example of my code, following the documentation from enum, let's call it problem.py which is imported in upper.py
import enum
class test(object):
def __init__(self, par1, par2):
# do stuff with the parameters and assign to object fields
# more object methods
class testlist(test, enum.Enum):
A = test(1,2)
B = test(3,4),
# a few more of these
When importing the module in which these classes are defined, I get the following error (edited to match the example):
File "upper.py", line 14, in <module>
from problem import test
File "problem.py", line 75, in <module>
class testlist(test, enum.Enum):
File "/usr/lib/python3.8/enum.py", line 252, in __new__
enum_member.__init__(*args)
TypeError: __init__() missing 1 required positional argument: 'par2'
I'm guessing that I'm misunderstanding how derived enums work, but from the documentation I can't figure out how I'm missing an argument.
(edit)
The goal is to have testlist values behave as test objects, which also define a few methods and override arithmetic operators, so I can do e.g., testlist.A + testlist.B. The enum isn't strictly necessary, but it's convenient for iteration and groups the values better than having them as global variables in the module.