class MyValues(enum.Enum):
value1 = 1
value2 = 2
value3 = 1
print(MyValues._member_names_)
Output would be a list with only the first two members [value1,value2]
I would also like to have value3 in that list, i tried with aenum with NoAlias setting but did not work. Is there any way to get all members even if they have duplicate values?
CodePudding user response:
_member_names_
is not part of the Enum documented public API. You should not use it.
__members__
is what you're looking for. It's a mapping from member names to members, including all aliases. You can use list(MyValues.__members__)
if you just want a list of the names.