how to count lines in a file ?

Alex Martelli aleax at aleax.it
Wed Jul 24 10:32:12 EDT 2002


Bo M. Maryniuck wrote:
        ...
>> >  for line in open(filename):
>> >      count += 1
> 
> In anyway this example probably does not work: looping over not sequence
> and you probably should use xreadlines().

Not with today's Python, 2.2.* -- looping over files and dicts is
perfectly well supported today (and since 7 months ago)...


Alex




More information about the Python-list mailing list