Why is the following attribute not found in Enum?
I am using Python 2.7.5 and I have set Enum as
pip install Enum
I wrote out the following code to validate an Enum.
from enum import Enum
class Color(Enum):
red = 'Hello'
blue = 'Trello'
green = 'Yello'
for name, attr in Color.__members__.items():
print(attr.value)
This tells me the error.
AttributeError: type object 'Color' has no attribute '__members__'
...
Why can't python get it __members__
?
+3
source to share