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

Reply via email to