Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #45236
| Date | 2013-05-13 13:00 +0200 |
|---|---|
| From | Jean-Michel Pichavant <jeanmichel@sequans.com> |
| Subject | Re: Python's sad, unimaginative Enum |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.1621.1368442906.3114.python-list@python.org> (permalink) |
----- 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 | Next — Next in thread | Find similar | Unroll 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