readlines problems - Newbie - Settled

John Purser NO_SPAM_jmpurser2 at attbi.com
Mon Apr 1 14:22:38 EST 2002


Thanks to Chris's link to the documentation I found that I can't do what I
was trying to do the way I was trying to do it.  Bottom line I've got to
pick a different path.  Fair enough.

Thanks for the help.

John Purser

"Chris Liechti" <cliechti at gmx.net> wrote in message
news:Xns91E3D6A2BD74Ccliechtigmxnet at 62.2.16.82...
> "John Purser" <NO_SPAM_jmpurser2 at attbi.com> wrote in
> news:k_1q8.146744$Yv2.44641 at rwcrnsc54:
> > I've got a little function:
> > def FindLine(Record):
> >      im1_Dif.seek(0)
> >      im1_Dif.readlines(Record - 1)
> >      test = im1_Dif.readline()
> >      print test
> >
> > When I call it I wind up with the same record in "test" whether I pass
> > it 1 or 10.  The readlines line reads a huge chunk of text with no
> > regard for lines at all.  I have no idea what is causing this.  Where
> > can I find the documentation on the file methods?  I can't find them
> > in the documentation. Can anyone tell me what's going on here?
>
> in the docs:
> http://www.python.org/doc/current/lib/bltin-file-objects.html
>
> you can see that this is a limit in bytes if even implemented.
>
> you can read all the lines in a buffer:
> >>> all = im1_Dif.readlines()
> and just work with the last one
> >>> test = all[-1]
>
> chris
> --
> Chris <cliechti at gmx.net>
>





More information about the Python-list mailing list