Is using range() in for loops really Pythonic?

Dave Parker daveparker at flamingthunder.com
Mon May 12 20:07:30 EDT 2008


On May 10, 8:19 pm, John Salerno <johnj... at NOSPAMgmail.com> wrote:
> It seems somewhat
> artificial to use the for loop to do something a certain number of
> times, like above.

I agree; it's a common flaw with lots of languages, not just Python.

I'd be inclined to use something like:

FOR 8 TIMES DO <statement>.

or:

REPEAT <statement> FOR 8 TIMES.

as a compromise between readability and machine-parsability.

If anyone has other suggestions, please post them here and I'll
implement one of them next weekend in Flaming Thunder.



More information about the Python-list mailing list