[Tutor] __iter__ loops, partitioning list among children

Alan Gauld alan.gauld at btinternet.com
Tue Aug 26 19:39:39 CEST 2008


"Eric Abrahamsen" <eric at ericabrahamsen.net> wrote

> So that's why I'm creating the iterator outside of the while loop in 
> the original code, and then using a repeated for loop with a break 
> to  step through all the events only once. Of course, the fact that 
> 5  isn't in there probably points to the source of my problems! The 
> solution might be assigning iterlist.next() to a variable, and 
> advancing the variable.

In that case wouldn't it be simpler to just use the index and
manually control its value? Iterators are wonderful things but
when I have to start bending things too far from vanilla I tend
to go back to first principles.

-- 
Alan Gauld
Author of the Learn to Program web site
http://www.freenetpages.co.uk/hp/alan.gauld 




More information about the Tutor mailing list