readlines() problem, more info

Steve Holden sholden at holdenweb.com
Mon Apr 1 18:33:16 EST 2002


"John Purser" <NO_SPAM_jmpurser2 at attbi.com> wrote in message
news:nd2q8.149996$ZR2.64791 at rwcrnsc52.ops.asp.att.net...
> Hello,
>
> I've got a little function:
>
> def FindLine(Record):
>      im1_Dif.seek(0)
>      temp = im1_Dif.readlines(Record)
>      lngCount = 0L
>      for line in temp:
>           print str(lngCount), '   ', line
>           lngCount += 1
>      test = im1_Dif.readline()
>      print test
>
>  That I'm using to trouble shoot a small script.  When I run this in the
> interactive mode it returns 136 lines to "temp" no matter what number I
pass
> to it.  Can anyone tell me why this is happening?
>
> I'm using Python 2.2 on Windows 2000.
>
So am I.

>>> import sys
>>> print sys.stdin.readlines.__doc__
Read until EOF using readline() and return a list containing the lines
        thus read. If the optional sizehint argument is present, instead of
        reading up to EOF, whole lines totalling approximately sizehint
bytes
        (possibly after rounding up to an internal buffer size) are read.

I suspect you are seeing the rounding up takinhg place.

regards
 Steve







More information about the Python-list mailing list