readlines with line number support?

Nikhil mnikhil at gmail.com
Wed May 14 14:54:20 EDT 2008


Arnaud Delobelle wrote:

> The standard Python way is using enumerate()
> 
> for i, line in enumerate(fp):
>     print "line number: " + lineno + ": " + line.rstrip()
> 

I guess you meant to say :

  for lineno, line in enumerate(fp):
      print "line number: " + lineno + ": " + line.rstrip()

Thanks.



More information about the Python-list mailing list