PEP 354: Enumerations in Python

Terry Hancock hancock at anansispaceworks.com
Tue Feb 28 16:54:38 EST 2006


On 28 Feb 2006 09:58:47 -0800
"sjdevnull at yahoo.com" <sjdevnull at yahoo.com> wrote:
> Add me to the "me, too!" list of people who think
> enumerations would be better off without > or <
> comparison.

+1 on "unordered"

Comparable enums do have use-cases (like the days of the
week), but I can't think of many of them. Also, there is
the point that even the days of the week is not a great
use of the ordering since it varies between locales, as
I think was pointed out in this thread.

The most compelling reason to have some kind of ordering is
just so you can iterate over them -- but dicts are
iterable without being ordered, so I see no reason
why enums couldn't be.

In C, enums are a rather shallow mask pulled over integers,
and as is common practice in C, the mask is routinely
ignored or removed.  I think that enums in Python, if added,
should be "strong enums" without this kind of ambiguous
behavior.

I also think though that the characterization of the
behavior of enumerated value instances is much more
important than the behavior of the enumeration collection
object, which is basically just a set, anyway.

Cheers,
Terry

-- 
Terry Hancock (hancock at AnansiSpaceworks.com)
Anansi Spaceworks http://www.AnansiSpaceworks.com




More information about the Python-list mailing list