Skip to content

Instantly share code, notes, and snippets.

@mslabko
mslabko / enum.py
Created April 7, 2011 08:17 — forked from GrAndSE/enum.py
ChoiceEnum is useful class to work with choices field ​​in Django. See http://docs.djangoproject.com/en/1.3/ref/models/fields/#choices
class Enum(object):
"""Unmodifiable enumeration class supports both sequential and named
creation:
>>> e = Enum('ZERO', 'ONE', TWO=2, FIVE=5)
>>> e.ZERO
0
>>> e.ONE
1
>>> e.FIVE