creating a subnested lists from a comma seperated string read from a file

Mark McEahern marklists at
Thu Aug 22 21:31:50 CEST 2002

> Thanks for all of the answers, after some more digging I found
> os.getlogin - its seems to be specific to Python 2.2...

Minor comment:  If you change the subject people who sort by subject to
follow a thread (perhaps only those who are braindead like me do that, but
anyway), folks really have no idea what you're referring to.

> How can I take each string element in my LIST variable with my comma
> seperated fields and turn them into a subnested lists with each comma
> seperated field as individual elements....


f = file(filename)
lines = f.readlines()

for line in lines:
  fields = line.split(",")
  for field in fields:

Ain't Python just purty?

// mark


More information about the Python-list mailing list