Am I the only one who would love these extentions? - Python3.0proposals (long)
Terry Reedy
tjreedy at udel.edu
Thu Nov 13 08:46:28 EST 2003
"Tim Jarman" <tim.jarman at lineone.net> wrote in message
news:mailman.682.1068673868.702.python-list at python.org...
> Enum("RED", "GREEN", "BLUE") creates constants RED=1, GREEN=2,
BLUE=3.
> Enum(RED=1, GREEN=2, BLUE=4) creates constants RED=1, GREEN=2,
BLUE=4.
> Enum("RED", "GREEN", "BLUE", BLACK=0) creates BLACK=0, RED=1,
GREEN=2,
> BLUE=3.
...
> I don't claim that this is the One True Answer but it works for me.
The apparent lack of there being One True Answer or even a close
approximation seems to be one of the barriers to a standard lib
module. Other people would rather that Enum("RED", "GREEN", "BLUE")
create constants RED='RED', GREEN='GREEN', BLUE='BLUE'. There have
been serious proposals on Python-Dev that the standard lib use
self-identifying constants that would at least print something more
meaningful than a number. On the other hand, some constants
(weekdays, months) do need to be ordered other than alphabetically.
Terry J. Reedy
More information about the Python-list
mailing list