Code Opinion - Enumerate

Stephen Hansen me+python at ixokai.io
Mon May 2 01:24:58 EDT 2016


On Sun, May 1, 2016, at 08:17 PM, Sayth Renshaw wrote:
> Just looking for your opinion on style would you write it like this
> continually calling range or would you use enumerate instead, or neither
> (something far better) ?

I can't comment on your specific code because there's too much noise to
it, but in general:

Using enumerate increases readability, and I use it whenever the idiom:

    for index, item in enumerate(thing):
        ...

is used.

Enumerate is your friend. Hug it.

-- 
Stephen Hansen
  m e @ i x o k a i . i o



More information about the Python-list mailing list