enum 0.2: Enumerations in Python

B

Ben Finney

Howdy all,

I've uploaded enum 0.2 to the Cheeseshop.

The main change is that enumeration values now export their enumtype,
index, and key (the things that define each value) as attributes.
Thanks to Bengt for making a convincing case in favour of this.

So now it's easier to ask an enumeration value about itself:
>>> from enum import Enum
>>> Weekdays = Enum('sun', 'mon', 'tue', 'wed', 'thu', 'fri', 'sat')
>>> print [str(v) for v in Weekdays]
['sun', 'mon', 'tue', 'wed', 'thu', 'fri', 'sat']
tue
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,776
Messages
2,569,603
Members
45,197
Latest member
Sean29G025

Latest Threads

Top