> For instance, if you have a (trivial) if...elif...else like this: > > if a == 0: > do_task_0() > elif a == 1: > do_task_1() > elif a == 2: > do_task_2() > else: > do_default_task() > > You could roll it up into a for...else statement like this: > > for i in range(3): > if a == i: > do_task[a]()
important "break" missing here... > else: > do_default_task() or otherwise this code will do_task_i *and* do_default_task()... -tkc -- http://mail.python.org/mailman/listinfo/python-list