Accessing EnumProperty values

When defining an EnumProperty, it is possible to associate with each of the EnumPropertyItems an integer value as well as an identifier. But how do you access or use these values?
For example, if a class definition contains

myEnum = bpy.props.EnumProperty(name="Mine",
    items=[('FIRST', "First", "", 1), ('SECOND', "Second", "", 2), ('THIRD', "Third", "", 3)])

accessing someObject.myEnum returns ‘FIRST’, ‘SECOND’ or ‘THIRD’. How do I get 1, 2 or 3 instead?

Best wishes,
Matthew

Hi Mathew. I got into the same situation, this is so annoying.

For the lack of a better answer, i was able to workaround it by creating a dictionary and generating the enum items from it.


#create a dictionary instead tuples
directions = {
    "BOTH": {"name": "Both", "value": -1},
    "FORWARD": {"name": "Forward", "value": 0},
    "BACKWARD": {"name": "Backward", "value": 1}
}

#generate items from dict
items = [(k, directions[k]['name'], directions[k]['value']) for k in directions.keys()]

print(items)

#acces the values from an enum property
print(directions['BOTH']['value'])

I must admit, I can’t even remember now what I was trying to do when I asked the question. But yes, using a Python dictionary is a sensible workaround.

Best wishes,
Matthew