Re: Early halt for iterating a_list and iter(a_list)

2008-08-22 Thread Steven D'Aprano
On Fri, 22 Aug 2008 07:23:18 -0700, Lie wrote: [...] >> iterators are once-only objects.  there's nothing left in "c" when you >> enter the inner loop the second time, so nothing is printed. >> >> > Ah, now I see. You have to "restart" the iterator if you want to use it > the second time (is it po

Re: Early halt for iterating a_list and iter(a_list)

2008-08-22 Thread Lie
On Aug 15, 9:55 pm, Fredrik Lundh <[EMAIL PROTECTED]> wrote: > Lie wrote: > > When you've got a nested loop a StopIteration in the Inner Loop would > > break the loop for the outer loop too: > > > a, b, c = [1, 2, 3], [1, 2, 3, 4], [1, 2, 3, 4, 5] > > > def looper(a, b, c): > >     for a_ in a: > >

Re: Early halt for iterating a_list and iter(a_list)

2008-08-15 Thread Fredrik Lundh
Lie wrote: When you've got a nested loop a StopIteration in the Inner Loop would break the loop for the outer loop too: a, b, c = [1, 2, 3], [1, 2, 3, 4], [1, 2, 3, 4, 5] def looper(a, b, c): for a_ in a: for b_ in b: for c_ in c: print a_, b_, c_ loope

Early halt for iterating a_list and iter(a_list)

2008-08-15 Thread Lie
When you've got a nested loop a StopIteration in the Inner Loop would break the loop for the outer loop too: a, b, c = [1, 2, 3], [1, 2, 3, 4], [1, 2, 3, 4, 5] def looper(a, b, c): for a_ in a: for b_ in b: for c_ in c: print a_, b_, c_ looper(a, b, c) #