[Python-Dev] constant/enum type in stdlib

Greg Ewing greg.ewing at canterbury.ac.nz
Wed Nov 24 00:41:50 CET 2010


Isaac Morland wrote:
> In any case my 
> suggestion of a new keyword was not meant to be taken seriously.

I don't think it need be taken entirely as a joke, either.
All the proposed patterns for creating enums that I've seen
end up leaving something to be desired. They violate DRY
by requiring you to write the class name twice, or they
make you write the names of the values in quotes, or some
other minor ugliness.

While it may be possible to work around these things with
sufficient levels of metaclass hackery and black magic, at
some point one has to consider whether new syntax might
be the least worst option.

-- 
Greg


More information about the Python-Dev mailing list