Unfortunately the Meta class can’t refer to the names in the outer class being defined:
In [11]: class MyChoices(Enum):
...: WHATEVER = "1"
...: SOMETHING = "2"
...:
...: class Meta:
...: SOME_GROUP = {WHATEVER, SOMETHING}
...: GROUPING = [
...: ['Something', [WHATEVER, SOMETHING]]
...: ]
...:
---------------------------------------------------------------------------
NameError Traceback (most recent call last)
<ipython-input-11-3fe4f79f24e8> in <module>
...
<ipython-input-11-3fe4f79f24e8> in Meta()
4
5 class Meta:
----> 6 SOME_GROUP = {WHATEVER, SOMETHING}
7 GROUPING = [
8 ['Something', [WHATEVER, SOMETHING]]
NameError: name 'WHATEVER' is not defined
We could use strings to refer to them (SOME_GROUP = {'WHATEVER', 'SOMETHING'}
) or special names in the main class. Given that enums already use some special names, and it’s cleaner syntax, I am in favour of the latter.