It's not just a Python thing, Java for example generally uses the idiom: for (Iterator it = list.iterator(); it.hasNext(); ) { Object next = it.next(); //Do stuff to next }
Horrible compared to the python idiom of course (though the latest version supports for (x : list){}) Ruby has something similar in: list.each do |item| print item end Again, not as nice as the python idiom IMHO (Though there may be better ways - I don't know Ruby very well). So really, all modern programming languages seem to prefer the loop-over-iterator idiom in preference to looping over a numerical range. -- http://mail.python.org/mailman/listinfo/python-list