On 28/05/2021 04:24, Ethan Furman wrote:
The flags RED, GREEN, and BLUE are all canonical, while PURPLE and
WHITE are aliases for certain flag combinations. But what if we have
something like:
class Color(Flag):
RED = 1 # 0001
BLUE = 4 # 0100
WHITE = 7 # 0111
...
So, like the enum.unique decorator that can be used when duplicate
names should be an error, I'm adding a new decorator to verify that a
Flag has no missing aliased values that can be used when the
programmer thinks it's appropriate... but I have no idea what to call it.
Any nominations?
The propery you are looking for IIUC is that if a bit position is 1 in
any member, then there is a member with only that bit set. I am seeing
these members as sets of elements (bit positions) and therefore you want
optionally to ensure that your enumeration has a name for every
singleton set, into which any member could be analysed.
Words like "basis", "complete", "analytic", or "indicator" (as in
indicator function) come to mind. I find "singletonian" attractive, but
no-one will know what it means, and I just made it up.
Jeff
_______________________________________________
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/7VN5Z5FSN3CH33KKQELX63L7JW6WEB2L/
Code of Conduct: http://python.org/psf/codeofconduct/