xrange question
Grant Edwards
grante at visi.com
Mon May 7 12:25:04 EDT 2001
In article <mailman.989210650.24674.python-list at python.org>, Paul Prescod wrote:
>John Flynn wrote:
>
>> Firstly, I can't see how 'xrange' does anything that can't be done more
>> efficiently with 'while'. I think xrange must have a purpose I'm not seeing.
>
>xrange gives you a simple way to do a for-loop over a large array. You
>could do a while instead but you can always replace for-loops with while
>loops. But for-loops are usually clearer than while-loops because the
>one statement does variable declaration, initialization and iteration.
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.
--
Grant Edwards grante Yow! I wonder if I should
at put myself in ESCROW!!
visi.com
More information about the Python-list
mailing list