Cameron Simpson writes: > On 08Nov2021 23:32, MRAB <pyt...@mrabarnett.plus.com> wrote:
> >A flag could be a member, but could a set of flags? > > Probably one flavour should raise a TypeError then with this comparison. > I wouldn't want "member flag present in SomeFlag.something" and > "set-of-members present in SomeFlag.something" to both be valid, If the latter is valid, so is the former, since "member flag" is representable as "singleton containing member flag". (I think this representation of sets of flags is the primary use case for IntFlag, as opposed to Flag or IntEnum.) If I really needed to distinguish, I wouldn't use a Enum type that can represent multiple members in one item, I'd use Python sets of Flags, . > I would rather punt the "set-of-members present" off to "<"/"<=" if > we want to say either (which of course we should be able to say). <MyFlag.1> < <MyFlag.2> == True since IntFlag is derived from int, but that's not what we want. You'd have to define __lt__ for every such flag type. For convenience, we would want a new Enum type in the stdlib. > Of course, I think resently we don't distinguish a flag combination > name (".nothing", ".red_and_blue"==0b11) from single flags > overtly. I think we really don't want to do that in the stdlib. Such flags would often support operations like intersection and set difference that could easily result in singletons, which then might be checked against an "allow set". If you care about the distinction between singleton-representing-element and other sets of flags, elements of the flag enum and sets of those elements need to be different types. _______________________________________________ Python-Dev mailing list -- python-dev@python.org To unsubscribe send an email to python-dev-le...@python.org https://mail.python.org/mailman3/lists/python-dev.python.org/ Message archived at https://mail.python.org/archives/list/python-dev@python.org/message/U3MK446WGHLNFET55S523NI2JKVMRRTW/ Code of Conduct: http://python.org/psf/codeofconduct/