xrange question

Remco Gerlich scarblac at pino.selwerd.nl
Mon May 7 12:44:11 EDT 2001


Grant Edwards <grante at visi.com> wrote in comp.lang.python:
> Definitely.  For the past year or so I've been maintianing C
> code written by somebody who didn't believe in for() loops.
> Everything is a while loop:
> 
>   i = 0;
>   while (i<FooBar)
>     {
>       [...]
>       i += 1;
>     }
> 
> I've not idea why they were written that way. I change them
> into for() loops as I run accross them, and it makes things
> much easer to understand.
 
I have that urge as well. That's because early in my CS study, we learned to
write correctness proofs for programs. And they only taught us how to do
that for while loops, since for loops etc are just syntactical sugar.

So in the back of my mind I still tend to think about setting up a
precondition, and loop with some invariant, until some guard condition isn't
true anymore.

But I only have it in Pascal and C, in Python it would be horrible :)

-- 
Remco Gerlich



More information about the Python-list mailing list