On Sat, Dec 12, 2020 at 07:01:55PM -0800, Ethan Furman wrote:
That's invalid. Duplicates allowed means:
class K( NamedValue): A = 1 B = 1
B is not an alias for A. Presumably one has the same number with different meaning. If that were an Enum:
>>> K.B K.A
Ah! Talking about Boy Looks, I had never noticed that behaviour before. (But then I don't regularly use duplicate Enum values.)
What is the reason for that behaviour in Enums?
I'm not following this either. Can you give an example of something that doesn't work with Enum (and shouldn't work) but should work with NamedValues?
Class MyEnum(Enum): ONE = 1 TWO = 2
MyEnum.ONE + 3 # TypeError
Class MyValue(NamedValue): ONE = 1 TWO = 2
MyValue.TWO + 3 5
Isn't this the solution to that?
class MyValue(int, Enum):
... ONE = 1 ... TWO = 2 ...
MyValue.TWO + 3