List and array code?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • derek / nul

    List and array code?

    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.

    Derek
  • mackstann

    #2
    Re: List and array code?

    On Sun, Aug 24, 2003 at 01:59:30AM +0000, derek / nul wrote:[color=blue]
    > 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.[/color]

    f = file("foobar.tx t", "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.tx t", "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.

    Comment

    Working...