List and array code?
mackstann
mack at incise.org
Sat Aug 23 22:15:35 EDT 2003
On Sun, Aug 24, 2003 at 01:59:30AM +0000, derek / nul wrote:
> Is there any list or array code that can load lines from a file?
>
> ie what I would like is to open a file and load line by line into a list or
> array.
>
> Any pointers most appreciated.
f = file("foobar.txt", "r")
myListOfLines = f.readlines()
Or if you really don't need to make list, but just want to loop through
the lines in a file:
f = file("foobar.txt", "r")
for line in f:
print line
--
m a c k s t a n n mack @ incise.org http://incise.org
A fool must now and then be right by chance.
More information about the Python-list
mailing list