5 ms·
I actually disagree with basically all of the points raised in this article. Sure, apparently Enum doesn't fit your particular desires for it - but there's good
by aiiane 13y ago
I actually disagree with basically all of the points raised in this article. Sure, apparently Enum doesn't fit your particular desires for it - but there's good reasons why those choices were made.
Colour = Enum('Colour', 'red, green')
There's a difference here between 'name' as in where in the namespace a value is listed, and 'name' as in what descriptive name something has. For instance, if you were to do this...
Colour = Enum('Colour', 'red, green')
Tint = Colour
Would you want the values from Tint to suddenly say that they're different values from the values in Colour, even though it's the same underlying object? I doubt it.
Similarly, regarding having to assign numbers: this makes a hell of a lot of sense any time you're trying to serialize things for interoperation between multiple services. There's a reason why protobufs do it this way as well: you get really powerful backwards-compatibility options, which you might not realize you need at first but become extremely handy down the line.
- TheSilentMan 13y agoI think the argument about specifying values is that it should be optional, not that it shouldn't exist.
- kemayo 13y agoWell, it is optional, in the sense that there's a provided syntax which doesn't require it. (The namedtuple-esque one.)