10 Sep
2021
10 Sep
'21
6:19 a.m.
My proposal is that iterating through a member of a Flag enum will return all the constituent members. Demonstration Setup: class FlagEnum(enum.Flag): A = enum.auto() B = enum.auto() C = enum.auto() FlagCombo = FlagEnum.A | FlagEnum.B My proposed change would cause the following to occur:
print(list(FlagCombo)) [FlagEnum.B, FlagEnum.A] print(list(FlagEnum.A)) [FlagEnum.A]
Compared to the current implementation:
print(list(FlagCombo)) Traceback (most recent call last): File "<stdin>", line 1, in <module> TypeError: 'FlagEnum' object is not iterable
What do you all think?