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


Groups > comp.lang.python > #45236

Re: Python's sad, unimaginative Enum

Path csiph.com!usenet.pasdenom.info!aioe.org!news.stack.nl!newsfeed.xs4all.nl!newsfeed4.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail
Return-Path <prvs=838e011f4=jeanmichel@sequans.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.096
X-Spam-Evidence '*H*': 0.81; '*S*': 0.00; 'subject:Python': 0.06; 'lawrence': 0.09; 'cc:addr:python-list': 0.11; 'python': 0.11; 'def': 0.12; 'attr': 0.16; 'subject:skip:u 10': 0.16; 'cc:addr:python.org': 0.22; 'print': 0.22; 'url:moin': 0.24; 'cc:2**0': 0.24; 'cc:no real name:2**0': 0.24; 'skip:_ 20': 0.27; 'header:In-Reply-To:1': 0.27; 'url:mailman': 0.30; 'url:wiki': 0.31; 'class': 0.32; 'url:python': 0.33; '-----': 0.33; 'skip:_ 10': 0.34; 'yield': 0.36; 'url:listinfo': 0.36; 'url:org': 0.36; 'thank': 0.38; 'little': 0.38; 'url:mail': 0.40; 'read': 0.60; "you're": 0.61; 'you.': 0.62; 'information': 0.63; 'received:194': 0.64; 'notice:': 0.67; 'person,': 0.68; 'privileged.': 0.69; 'disclose': 0.74; 'to:addr:yahoo.co.uk': 0.84; 'medium.': 0.91
X-IronPort-AV E=Sophos;i="4.87,662,1363129200"; d="scan'208";a="1454150"
X-Virus-Scanned amavisd-new at zimbra.sequans.com
Date Mon, 13 May 2013 13:00:36 +0200 (CEST)
From Jean-Michel Pichavant <jeanmichel@sequans.com>
To Mark Lawrence <breamoreboy@yahoo.co.uk>
In-Reply-To <kmqbgk$dec$1@ger.gmane.org>
Subject Re: Python's sad, unimaginative Enum
MIME-Version 1.0
X-Mailer Zimbra 7.2.2_GA_2852 (ZimbraWebClient - GC7 (Linux)/7.2.2_GA_2852)
Content-Type text/plain; charset="utf-8"
Content-Transfer-Encoding base64
Cc python-list@python.org
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.15
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <http://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.1621.1368442906.3114.python-list@python.org> (permalink)
Lines 18
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1368442906 news.xs4all.nl 15989 [2001:888:2000:d::a6]:52392
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:45236

Show key headers only | View raw


----- Original Message -----
> That's the title of this little beast
> http://www.acooke.org/cute/Pythonssad0.html if anybody's interested.
> 
> --
> If you're using GoogleCrap™ please read this
> http://wiki.python.org/moin/GoogleGroupsPython.
> 
> Mark Lawrence
> 
> --
> http://mail.python.org/mailman/listinfo/python-list
> 

python 2.5

class Enum:
  class __metaclass__(type):
    def __iter__(self):
      for attr in sorted(dir(self)):
        if not attr.startswith("__"):
          yield getattr(self, attr)

class Colours(Enum):
  RED = "red"
  GREEN = "green"

for c in Colours:
  print c

green
red


JM


-- IMPORTANT NOTICE: 

The contents of this email and any attachments are confidential and may also be privileged. If you are not the intended recipient, please notify the sender immediately and do not disclose the contents to any other person, use it for any purpose, or store or copy the information in any medium. Thank you.

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


Thread

Re: Python's sad, unimaginative Enum Jean-Michel Pichavant <jeanmichel@sequans.com> - 2013-05-13 13:00 +0200
  Re: Python's sad, unimaginative Enum Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-05-14 02:00 +0000

csiph-web