How do you limit the # of lines Read?

James Matthews nytrokiss at gmail.com
Tue Sep 18 23:45:10 CEST 2007


for i in range(<number of times you want to read a line>):
   line = file.readline()

On 9/18/07, John Machin <sjmachin at lexicon.net> wrote:
>
> On Sep 19, 6:59 am, kou... at hotmail.com wrote:
> > I am working on a loop for my code and was wondering if there is a way
> > to limit the number of lines read through?  I'd hate to cut the test
> > file in order to run the code in the testing phase.  Can you add a
> > value in the parenthesis of the readline() function?
> >
> > t = string.readline()  # Limit this somehow?
>
> *STRING*.readline() ????
>
>
> --
> http://mail.python.org/mailman/listinfo/python-list
>



-- 
http://www.goldwatches.com/
http://www.jewelerslounge.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20070918/61d9397e/attachment.html>


More information about the Python-list mailing list