mg at lazybytes.net
Sat Jul 4 04:36:00 CDT 2009
Greg Ward <greg-hg at gerg.ca> writes:
> On Fri, Jul 3, 2009 at 6:59 PM, Stefano Mioli<jstevie at gmail.com> wrote:
>> + for line in lines:
>> + lineindex += 1
> I have seen 'count' used for this purpose elsewhere in Hg. And you
> should initialize 'count = 0' right before the loop.
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):
Compared to your code this will count lines from zero instead of one, so
you should add one when printing the line number.
VIFF (Virtual Ideal Functionality Framework) brings easy and efficient
SMPC (Secure Multiparty Computation) to Python. See: http://viff.dk/.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Size: 196 bytes
Desc: not available
Url : http://selenic.com/pipermail/mercurial-devel/attachments/20090704/3f8ed372/attachment.pgp
More information about the Mercurial-devel