[Python-ideas] PEP for enum library type?
Greg Ewing
greg.ewing at canterbury.ac.nz
Wed Feb 13 00:19:16 CET 2013
Ethan Furman wrote:
> If you don't mind verbose, we could always go for something like:
>
> class Color(Enum):
> start_defs()
> BLACK
> RED, GREEN, BLUE
> CYAN, YELLOW, MAGENTA
> end_defs()
Or
class Color(Enum):
values(BLACK,
RED, GREEN, BLUE,
CYAN, YELLOW, MAGENTA)
where values() ignores its arguments and ends the
definition phase.
This would also provide a way to avoid relying on
language guarantees of evaluation order. The initial
lookup of the names could assign arbitrary values to
them, and then values() could remap them to sequential
values based on the order it receives them in.
--
Greg
More information about the Python-ideas
mailing list