Enum questions.

Ethan Furman ethan at stoneleaf.us
Wed Apr 13 17:13:06 EDT 2016


On 04/13/2016 07:21 AM, Ethan Furman wrote:
> On 04/13/2016 07:07 AM, Marko Rauhamaa wrote:
>
>>      class Color(enum.Enum):
>>          red
>>          blue
>>          green
>>
>>
>> This last one is to the point but raises a NameError.
>
> Using the aenum library that last one is possible.  It also has
> NamedConstant and a metaclass-derived NamedTuple! </shameless plug>

Oh, and to keep it mostly safe, the magic that creates the missing names 
is turned off as soon as something real happens, like creating a 
property or a method.

--
~Ethan~




More information about the Python-list mailing list