easy question on input files in Python

Bragi Baldursson bragi at hks.com
Wed Dec 6 16:35:46 EST 2000


handle = open('file.inp', 'r')
lines = handle.readlines()
for line in lines:
   print line

or in a while loop.

while 1:
    line = handle.readline()
    if line:
        print line
     if not line:
        break

Bragi


jsolack at my-deja.com wrote:

> I am just messing around with Python and I only have the tutorial off
> of python.org.  I was wondering how I would set up a while loop that
> says "while not end of file" in python?  I would like to read through
> an input file and i do not know the sytax for that!  Thanks!
>
> Jason
>
> Sent via Deja.com http://www.deja.com/
> Before you buy.

--
___________________________________________________

Bragi Baldursson
Hibbitt, Karlsson, & Sorensen, Inc.
web:  www.hks.com             mailto: bragi at hks.com
Phone: (401) 727-4380 x5586   Fax: (401) 727-4208
___________________________________________________


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20001206/451107c1/attachment.html>


More information about the Python-list mailing list