[Python-ideas] PEP for enum library type?

Georg Brandl g.brandl at gmx.net
Wed Feb 13 00:59:08 CET 2013


Am 13.02.2013 00:08, schrieb Steven D'Aprano:
> On 13/02/13 06:50, Barry Warsaw wrote:
>> On Feb 12, 2013, at 04:05 PM, Joao S. O. Bueno wrote:
>>
>>> That is too much ' ' typing - I think it would be ok, to have it like that,
>>> but a helper function that would work just like the namedtuple call: Color =
>>> Enum("Color", "RED GREEN BLUE", int)
>>
>> How about:
>>
>>      >>>  from flufl.enum import make
>>      >>>  make('Colors', 'RED GREEN BLUE'.split())
>>      <Colors {RED: 1, GREEN: 2, BLUE: 3}>
> 
> 
> That reminds me of namedtuple. I could live with something close to that.
> 
> Like namedtuple, it should do the split for you.

And like namedtuple, it's ugly as hell :)

Georg




More information about the Python-ideas mailing list