Choices class

1
2
3
4
5
6
7
8
9
class Choices(object):
    def __init__(self, *args):
        self._choices = []
        for i, arg in enumerate(args):
            setattr(self, arg[0], i)
            self._choices.append((i, arg[1]))

    def __iter__(self):
        return iter(self._choices)

More like this

  1. i18n base model for translatable content by foxbunny 4 years, 10 months ago
  2. Handling choices the right way by mallipeddi 5 years, 6 months ago
  3. Automatic Manager Choice Filters by nipuL 4 years, 4 months ago
  4. Dynamic tabular inlines with optional drag-n-drop sorting by Aneon 4 years ago
  5. MultiSelectField with comma separated values (Field + FormField) by quinode 1 year ago

Comments

petar (on November 11, 2008):

This class if freaking awesome!

#

(Forgotten your password?)