[Python-ideas] PEP for enum library type?

Guido van Rossum guido at python.org
Tue Feb 12 22:29:17 CET 2013


Please. Anything *except*

class Color(Enum):
  RED, BLUE, GREEN

And not this eiter:

class Color(Enum):
  RED
  BLUE
  GREEN

On Tue, Feb 12, 2013 at 12:58 PM, Eli Bendersky <eliben at gmail.com> wrote:
> On Tue, Feb 12, 2013 at 11:59 AM, Guido van Rossum <guido at python.org> wrote:
>>
>> After all the defenses I still don't like Tim's proposed syntax. Color me
>> Barry.
>
>
> In this case, I see no reason not to use Barry's flufl.enum - it's pretty
> good and has been around for a while. The main advantage of Tim's
> implementation syntax (wasn't it Michael Foord who originally proposed it?)
> is that it lets us do less typing which is great. IOW, sure with flufl.enum
> I can do this and be reasonably happy:
>
>
> class Color(Enum):
>   RED = 1
>   BLUE = 2
>   GREEN = 3
>
> 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.
>
>



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



More information about the Python-ideas mailing list