You don't need to copy the list; but if you don't, your original list will be emptied.
Len(rows) recalculates each time the while loop begins. Now that I think of it, "rows != []" is faster than "len(rows) > 0." By the way, you can also do this using (gasp) a control index: def grouprows(rows): index = 0 while len(rows) > index: rowspan = rows[index]["rowspan"] yield rows[index:rowspan + index] index += rowspan ...which kind of brings us back to where we started. -- http://mail.python.org/mailman/listinfo/python-list