En Wed, 03 Oct 2007 08:46:31 -0300, <[EMAIL PROTECTED]> escribi�:

> in python2.4, i read lines from a file with
>
> for lineNum, line in enumerate(f): ...
>
> However, lineNum soon overflows and starts counting backwards. How do
> i force enumerate to return long integer?

(what kind of files are you using? enumerate overlows after more than two  
billion lines... is that "soon" for you?)

I'm afraid neither iterate nor itertools.count will generate a long  
integer; upgrading to Python 2.5 won't help. I think the only way is to  
roll your own counter:

lineNum = 0
for line in f:
   ...
   lineNum += 1

-- 
Gabriel Genellina

-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to