[Python-ideas] adopt an enum type for the standard library?

Christian Heimes lists at cheimes.de
Wed Jan 23 14:16:48 CET 2008

Mark Summerfield wrote:
> There is an enum module in PyPI 
> http://pypi.python.org/pypi/enum/
> and there are several versions in the Python Cookbook.
> Wouldn't one of these be worth adopting for the standard library?

It might be worth adding an enum to Python 2.6. I'm +0 on it.

The enum implementation from pypi is not sufficient for Python core. I
don't like its __cmp__ and __hash__ code. I also miss the feature to set
a start value or to skip values:

>>> enum = Enum("error=-1", "ok", "also_ok", "someother=1000", "last")
>>> enum.error
>>> enum.ok
>>> enum.also_ok
>>> enum.someother
>>> enum.last


More information about the Python-ideas mailing list