how to count lines in a file ?

Alex Martelli aleax at aleax.it
Fri Jul 26 04:28:59 EDT 2002


Fredrik Lundh wrote:

> Alex Martelli wrote:
> 
>> > (does anyone here even know that readline takes an optional
>> > integer argument, and what it does? ;-)
>>
>> I would hope so, given that
>> http://www.python.org/doc/current/lib/bltin-file-objects.html
>> documents it so clearly.
> 
> does anyone here think that when I asked that question, I did
> that because I didn't know, and wanted someone to look it up
> for me? ;-)

"look it up"...?  You asked, or rather wondered with a smilie,
whether anybody knew.  I opined some did, explained the reason
for my opinion, and, as I was at it, took the occasion to remind 
some of those who didn't.  Not you, for sure, o mighty exhalted
uppercasedbot, but, last I checked, you're not the only one
reading this thread.

And as it happens some _other_ readers did NOT know about the
differences between the seemingly-identical numerical parameter
to readline and readlines, witness the grumbling about it in
follow-ups.  Now, why the BDFL things the (strict) numerical
parameter to *readline* is the design error, rather than the
(advisory) one to *readlines*, which is the one which attracted
the grumblings, might perhaps be interesting to discuss.  But
(my bias) discussions are often more interesting when various
discussants and onlookers share some fundamental knowledge.


Alex




More information about the Python-list mailing list