how to count lines in a file ?

Kristian Ovaska kristian.ovaska at helsinki.fi
Sat Jul 27 05:10:07 EDT 2002


bokr at oz.net (Bengt Richter):
[f.readlines(N)]
>That bothers me. ISTM it should return as many lines as
>will fit in N bytes, but no more. Otherwise you have no
>memory use protection against a single monster line

You can't have complete protection in any case: what if there is a
line of length > N? (Or length >> N...)

-- 
Kristian Ovaska <kristian.ovaska at helsinki.fi>



More information about the Python-list mailing list