[Python-ideas] constant/enum type in stdlib
Georg Brandl
g.brandl at gmx.net
Fri Feb 1 10:12:24 CET 2013
Am 30.01.2013 17:26, schrieb Antoine Pitrou:
>> With a Python 3 metaclass that provides default values for *looked up*
>> entries you could have this:
>>
>> class Color(Enum):
>> RED, WHITE, BLUE
>
> This relies on tuple evaluation order, and would also evaluate any
> other symbol looked up from inside the class body (which means I
> cannot add anything else than enum symbols to the class).
>
> In other words, I'm afraid it would be somewhat fragile ;)
And it breaks static code checkers like pyflakes.
Georg
More information about the Python-ideas
mailing list