Newbie Question

Arnaldo Riquelme javanet at dynacap.com
Fri Apr 28 00:00:27 CEST 2000


Suppose I have a file name tick.tkr that looks like this

SUNW.
MFST.
FOO.
SPAM.
MOO.
End_Of_File

I want to read the file into a list

myfile = open("tick.tkr", "r")
mylist = myfile.readlines()

Now I have mylist with the contents of tick.tkr. "mylist" looks like this
['SUNW.\012', 'MSFT.\012', ..........'End_of_File/012']

How do I read the file into a list without getting the newline character, so
I can accomplish this

for tic in mylist:
    #create file tic.prn

I know the other P language has something like 'chop' or something like
that, but I'm not going there.

Thanks


Arnaldo,









More information about the Python-list mailing list