[Python-ideas] adopt an enum type for the standard library?
Mark Summerfield
mark at qtrac.eu
Wed Jan 23 09:59:54 CET 2008
AFAIK if you want enumerations you must either create your own, or use a
third party module, or use namedtuple:
Files = collections.namedtuple("Files", "minimum maximum")(1, 200)
...
x = Files.minimum
Using:
MINIMUM, MAXIMUM = 1, 200
is often inconvenient, since you might have several different ones. Of
course you could do:
MIN_FILES = 1
MIN_DIRS = 0
Personally, I like enums and consider them to be a fundamental, but I
don't like the above approaches.
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?
--
Mark Summerfield, Qtrac Ltd., www.qtrac.eu
More information about the Python-ideas
mailing list