I have 2 enums as below:
class flower1(Enum):
Jasmine = "Jasmine"
Rose = "Rose"
Lily = "Lily"
class flower2(Enum):
Jasmine = "Jasmine"
Sunflower="Sun flower"
Lily = "Lily"
how to find if the enum values are equal and if not find diff of contents in the above two enums?
Enum
s are directly iterable, so if you only need the difference and not which Enum has which member, you can do:
>>> set([m.name for m in flower1]) & set([m.name for m in flower2])
set(['Jasmine', 'Lily'])