[Python-Dev] constant/enum type in stdlib

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


Antoine Pitrou wrote:

> Constants = make_constants('Constants', 'SOME_CONST OTHER_CONST',   
>                            values=range(1, 3))
> 
> Again, auto-enumeration is useless since it's trivial to achieve
> explicitly.

But seeing as it's going to be a common thing to do, why not
make it the default?

When defining an enum, often you don't *care* what the
underlying values are, so assigning sequential natural numbers
is as good a default as any.

In fact, with the Pascal concept of an enumerated type you
don't get any choice in the matter. It's only in the C family
that you get this bastardised conflation of enumerations with
arbitrary named constants...

-- 
Greg


More information about the Python-Dev mailing list