On Sat, Apr 11, 2020 at 4:21 AM Rhodri James email@example.com wrote:
Since the introduction of enumerate() lo! these many moons ago, I find I almost never write range(len(x)) as a loop iterable.
Out of curiosity, I just grepped about 300k lines of source:
234 - enumerate() in for loops 140 - zip() in for loops 12 - range(len()) in for loops
About half of those 12 range uses are interfacing to extension modules that only provide an indexing interface to array-like data, so really no way around it... The remainder are in unit tests where we are just sloppily generating N-long test data values, where it could be better formulated, but no one cares enough to change it.