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?
_______________________________________________
Python-ideas mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3/lists/python-ideas.python.org/
Message archived at
https://mail.python.org/archives/list/[email protected]/message/PT7DZKXRFP4EUALYTVCILPNFEQV25KHY/
Code of Conduct: http://python.org/psf/codeofconduct/