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. Automatic Manager Choice Filters by nipuL 3 years ago
  2. Model Choices Helper by pmclanahan 2 years ago
  3. Handling choices the right way by mallipeddi 4 years, 3 months ago
  4. ModelMixin by eallik 1 year, 3 months ago
  5. Online boolean switch in the admin list by sasha 4 years, 5 months ago

Comments

petar (on November 11, 2008):

This class if freaking awesome!

#

(Forgotten your password?)