mulit-dimensional lists

Alex Martelli aleax at aleax.it
Wed Oct 8 05:15:40 EDT 2003


saoirse_79 wrote:

> Thanks for your help...what I exactly want to do is as follows: I
> have a file (a multiple sequence alignment to be exact) and I want
> each line in that file to be a separate list, hence creating a list
> of lists!

I'm not clear about how you want to turn each of the lines into a
list, but that matters only up to a point -- e.g., if you're
splitting each line on whitespace, then

listoflists = [ line.split() for line in open('thefile.dat') ]

would give you the effect you desire.


Alex





More information about the Python-list mailing list