News for hackers. Stuff that matters.
Re:Python's sad, unimaginative Enum by aiiane on Saturday May 11, 2013 @02:07PM (#5691451)
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.

Re:Python's sad, unimaginative Enum by TheSilentMan on Saturday May 11, 2013 @03:07PM (#5691726)
I think the argument about specifying values is that it should be optional, not that it shouldn't exist.
Re:Python's sad, unimaginative Enum by kemayo on Saturday May 11, 2013 @04:26PM (#5691988)
Well, it is optional, in the sense that there's a provided syntax which doesn't require it. (The namedtuple-esque one.)