Path: csiph.com!news.swapon.de!fu-berlin.de!uni-berlin.de!not-for-mail From: Ethan Furman Newsgroups: comp.lang.python Subject: Re: Enum questions. Date: Wed, 13 Apr 2016 14:13:06 -0700 Lines: 21 Message-ID: References: <570E1B98.4080904@rece.vub.ac.be> <878u0htxe5.fsf@elektro.pacujo.net> <570E55F4.3050006@stoneleaf.us> <570EB662.6070803@stoneleaf.us> Mime-Version: 1.0 Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit X-Trace: news.uni-berlin.de SVC5gRYEQTkmUxjjhVOC4QSzGdXjbN452FapaxngRX/w== Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.007 X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; 'method.': 0.05; 'raises': 0.07; 'blue': 0.09; 'from:addr:ethan': 0.09; 'from:addr:stoneleaf.us': 0.09; 'from:name:ethan furman': 0.09; 'message-id:@stoneleaf.us': 0.09; 'oh,': 0.09; 'magic': 0.16; 'received:io': 0.16; 'received:psf.io': 0.16; 'wrote:': 0.16; 'creates': 0.18; 'library': 0.20; 'am,': 0.23; 'header:In-Reply- To:1': 0.24; 'header:User-Agent:1': 0.26; 'mostly': 0.27; '~ethan~': 0.29; 'creating': 0.30; 'point': 0.33; 'class': 0.33; 'something': 0.35; 'but': 0.36; 'possible.': 0.36; 'to:addr :python-list': 0.36; 'subject:: ': 0.37; 'missing': 0.37; 'green': 0.38; 'names': 0.38; 'turned': 0.38; 'to:addr:python.org': 0.40; 'real': 0.62; 'charset:windows-1252': 0.62; 'skip:n 10': 0.62; 'soon': 0.65; 'ethan': 0.91; 'furman': 0.91 User-Agent: Mozilla/5.0 (X11; Linux i686; rv:31.0) Gecko/20100101 Thunderbird/31.2.0 In-Reply-To: <570E55F4.3050006@stoneleaf.us> X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Mailman-Original-Message-ID: <570EB662.6070803@stoneleaf.us> X-Mailman-Original-References: <570E1B98.4080904@rece.vub.ac.be> <878u0htxe5.fsf@elektro.pacujo.net> <570E55F4.3050006@stoneleaf.us> Xref: csiph.com comp.lang.python:106965 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! 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~