[Python-ideas] constant/enum type in stdlib (original) (raw)

Greg Ewing greg.ewing at canterbury.ac.nz
Thu Jan 31 09:17:35 CET 2013


Cameron Simpson wrote:

How about this:

Color = enum(RED=None, WHITE=None, BLUE=None, yellow=9)

You see, this is the problem -- there are quite a number of these solutions, all about as good as each other, with none of them standing out as obviously the right choice for stdlib inclusion.

Michael Foord's solution has promise, though, as it manages to eliminate all of the extraneous cruft and look almost like it's built into the language.

Plus it has the bonus of making you go "...??? How the blazes does that work?" the first time you see it. :-)

-- Greg



More information about the Python-ideas mailing list