[Python-ideas] PEP for enum library type?

Georg Brandl g.brandl at gmx.net
Wed Feb 13 08:34:21 CET 2013


Am 13.02.2013 08:21, schrieb Antoine Pitrou:
> On Wed, 13 Feb 2013 00:57:38 +0100
> Georg Brandl <g.brandl at gmx.net> wrote:
>> > IMHO, none of these approach the simplicity and explicitness of this API:
>> > 
>> > class Color(Enum):
>> >     RED = 1
>> >     GREEN = 2
>> >     BLUE = 3
>> 
>> We could even allow
>> 
>> class Color(Enum):
>>     RED = 1
>>     GREEN = ...       # becomes 2
>>     BLUE = ...        # 3
>>     MAGENTA = 5
>>     FLUFL = ...       # 6
> 
> The fact that the ellipsis variant requires *more* typing sounds a bit
> wrong to me. The common case should be the easiest to type.

Well, nobody forbids you from writing the integers out.  But one of the
complaints was that you shouldn't need to know or write the constant
values (and "..." is shorter than "val()" which was proposed for that
purpose).

And for stringy enums that argument is void :)

Georg




More information about the Python-ideas mailing list