[Python-ideas] PEP for enum library type?

Guido van Rossum guido at python.org
Tue Feb 12 22:59:44 CET 2013


And I'm of the opinion that the most fundamental property of an enum
is that it doesn't print as an int.

On Tue, Feb 12, 2013 at 1:19 PM, Tim Delaney
<timothy.c.delaney at gmail.com> wrote:
> On 13 February 2013 07:58, Eli Bendersky <eliben at gmail.com> wrote:
>>
>>
>> But in 99% of the cases in Python code I absolutely don't care about the
>> values of these enumerations (*), so I'd much, *much* rather write:
>>
>> class Color(Enum):
>>   RED, BLUE, GREEN
>>
>> Yes, the implementation is messy, but it can be documented and tested
>> well, and it's fairly small and confined. But this is a matter of
>> preference, and I can see your point (Guido) about preferring the more
>> explicit syntax in order to avoid too much magic.
>>
>> Eli
>>
>> (*) And where I do care, I'd still enjoy them being generated
>> automatically.
>
>
> I'm of the opinion that the most fundamental property of an enum is that it
> can generate its values automatically. Everything else is a nice-to-have,
> but without that property it's not much use as an enum.
>
> Tim Delaney



--
--Guido van Rossum (python.org/~guido)



More information about the Python-ideas mailing list