On Feb 25, 7:02 am, Tim Chase <python.l...@tim.thechases.com> wrote: > Python 3 introduced a variable tuple assignment which I > suspect[*] would work in this context: > > for first, *rest in L: # note the asterisk > print first > for x in rest: > do_stuff(x) > > [*] not having py3 on this machine, I can't readily verify this.
Seems fine under 3.1. Cool. >>> L = ((1,2,3), (4,), (5,), (6,7) ) >>> for first, *rest in L: print('first',first,end=' ') print('rest',rest) first 1 rest [2, 3] first 4 rest [] first 5 rest [] first 6 rest [7] -- http://mail.python.org/mailman/listinfo/python-list