Storing lines from a text file

Kirk McDonald mooquack at suad.org
Sun Jan 29 18:40:17 EST 2006


bradfordh at gmail.com wrote:
> With what kind of list? I don't see how I can do it with a list unless
> I create one indefinate list and use the objects in the indefinate list
> for the names of  the lists to hold the lines of text. Is that how you
> are suggesting that I do it?
> 

You're thinking too hard. Say you want to read in all the lines from the 
file object f and just print them out one at a time:

lines = f.getlines()
for line in lines:
     print line

Simple.

-Kirk McDonald



More information about the Python-list mailing list