[RFC] checkpatch.py

Brodie Rao dackze at gmail.com
Sat Jul 4 19:42:47 CDT 2009


On Jul 4, 2009, at 7:08 PM, Greg Ward wrote:

> On Sat, Jul 4, 2009 at 5:36 AM, Martin Geisler<mg at lazybytes.net>  
> wrote:
>> The built-in enumerate function takes a sequence and add indices to  
>> it:
>>
>>    >>> list(enumerate(["foo", "bar", "baz"]))
>>    [(0, 'foo'), (1, 'bar'), (2, 'baz')]
>>
>> You use it like this:
>>
>>  for count, line in enumerate(lines):
>>      # ...
>
> Careful: if 'lines' is actually a file object, this will suck the
> entire file into memory and return a big list.  (At least in Python
> 2.x: has enumerate() has been turned into an iterable in Py3k?)  There
> is still room for the "count += 1" idiom.

enumerate() has always returned an iterator.



More information about the Mercurial-devel mailing list