On Sat, Aug 30, 2008 at 10:56 AM, Arnaud Delobelle <arnodel@googlemail.com> wrote:

Finally, my function works gracefully with nested loops:

for i, i_last in flaglast(items):
   for j, j_last in flaglast(jtems):

without the need for a 'named loop', about which I feel very circumspect.

Unfortunately, your function has to get the N+1st item before the body processes the Nth element so if getting the elements has side effects and the body might break, then this changes the behavior of the loop. With an explicit call to an <is this the last> function, we know exactly when it will peek ahead in the list.

--- Bruce