On May 30, 5:58 pm, Chris Angelico <ros...@gmail.com> wrote: > The alternative would be an infinite number of iterations, which is far far > worse.
There was one heavyweight among programming teachers -- E.W. Dijkstra -- who had some rather extreme views on this. He taught that when writing a loop of the form i = 0 while i < n: some code i += 1 one should write the loop test as i != n rather than i < n, precisely because if i got erroneously initialized to some value greater than n, (and thereby broke the loop invariant), it would loop infinitely rather than stop with a wrong result. -- http://mail.python.org/mailman/listinfo/python-list