[Python-ideas] PEP for enum library type?
Eric Snow
ericsnowcurrently at gmail.com
Wed Feb 13 07:49:01 CET 2013
On Tue, Feb 12, 2013 at 6:07 PM, Eric Snow <ericsnowcurrently at gmail.com> wrote:
> At the same time, Steven D'Aprano's proposition of "the underlying
> value is irrelevant" and "must be bitwise comparable" appeals to me.
> If the underlying values matter then I'd call it a "constant" rather
> than an "enum". A proper enum type would remove the temptation to use
> the underlying value.
Here's an implementation of what I'm talking about:
http://code.activestate.com/recipes/578455/
Each enum value is simply an object and not backed by any underlying
value. The bitwise operators are implemented. The implementation is
a little rough, but hopefully gets the idea across.
-eric
More information about the Python-ideas
mailing list