Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #106965

Re: Enum questions.

From Ethan Furman <ethan@stoneleaf.us>
Newsgroups comp.lang.python
Subject Re: Enum questions.
Date 2016-04-13 14:13 -0700
Message-ID <mailman.88.1460581932.15650.python-list@python.org> (permalink)
References (2 earlier) <nelir9$163$1@ger.gmane.org> <mailman.72.1460555456.15650.python-list@python.org> <878u0htxe5.fsf@elektro.pacujo.net> <570E55F4.3050006@stoneleaf.us> <570EB662.6070803@stoneleaf.us>

Show all headers | View raw


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~

Back to comp.lang.python | Previous | NextPrevious in thread | Find similar | Unroll thread


Thread

Re: Enum questions. Grant Edwards <grant.b.edwards@gmail.com> - 2016-04-13 13:50 +0000
  Re: Enum questions. Marko Rauhamaa <marko@pacujo.net> - 2016-04-13 17:07 +0300
    Re: Enum questions. Ethan Furman <ethan@stoneleaf.us> - 2016-04-13 07:21 -0700
    Re: Enum questions. Ethan Furman <ethan@stoneleaf.us> - 2016-04-13 14:13 -0700

csiph-web