Is using range() in for loops really Pythonic?

Ivan Illarionov ivan.illarionov at gmail.com
Mon May 12 01:18:37 EDT 2008


>> In such cases, the name 'dummy' is conventionally bound to the items
>> from the iterator, for clarity of purpose
[..]
> If a value isn't used, then I think the most clear name for it is
> "unused".
[...]

Maybe my brain works differently, but I find both "dummy" and "unused" 
are extremely confusing names for loop counters. The loop begins to look 
like it doesn't iterate at all if its counter is dummy or unused.

If it *counts* it is *used* and it's *not* dummy.

Why reinvent the wheel when "a common identifier naming convention is for 
the loop counter to use the variable names i, j and k (and so on if 
needed)" (from Wikipedia http://en.wikipedia.org/wiki/Loop_counter )

-- Ivan



More information about the Python-list mailing list