Is using range() in for loops really Pythonic?
Ivan Illarionov
ivan.illarionov at gmail.com
Mon May 12 02:56:47 EDT 2008
On Mon, 12 May 2008 16:24:23 +1000, Ben Finney wrote:
[...]
> That is also regrettably common in Python code. It still suffers from
> being unnecessarily ambiguous, since there are *also* plenty of loops
> using 'i', 'j', etc. where the loop counter *is* used.
>
> Differentiating these use cases by appropriate naming is, IMO, worth the
> effort of choosing a meaningful name.
Even if the counter is not used inside the loop's body it's still in
control of the whole loop and, IMO, any special discriminating and non-
conventional name doesn't worth the added confusion.
-- Ivan
More information about the Python-list
mailing list