[Tutor] easy newbie questions: text file to list?

ashleigh smythe absmythe@ucdavis.edu
Mon May 19 21:53:06 2003


Hello.  I have a text file that looks like this:

Y16911
AF202148
U81576
AF202159
...

I can get Python2.2 on my Linux to read the file with file.read() which
makes it look like this:
'Y16911\nAF202148\nU81576\n...'

I would like to turn these items into a list (that I can save, not just
work with in the interpreter) but I'm confused about strings and
pickling etc.  I know that to save a list I have to pickle it (and I've
succeeded at that for another list) but how do I get these into a list? 
Do I have to convert these things to strings first (I guess it is one
big string now)?  I know that pickling turns things into strings but
they have all kinds of funny characters in them when I look at a pickled
file (with say cat) so it doesn't seem like that's the way to make it a
list.  

Thanks for any help/documentation pointers!

Ashleigh



***************************
Ashleigh B. Smythe
Graduate Research Assistant
Department of Nematology
UC Davis
Davis, CA 95616
phone 530-754-4321
email absmythe@ucdavis.edu