python -- question with list.pop(0)
Terry Reedy
tjreedy at udel.edu
Mon Jun 7 08:29:08 EDT 2004
"David Stockwell" <winexpert at hotmail.com> wrote in message
news:BAY2-F110eI4ks6AM1w0001905d at hotmail.com...
> ourFile = open(fileNamesList[0],'r')
> strData = ourFile.read()
>From what you do below, you want .readlines()
> ourFile.close()
>
> records = []
> print "split 0.5"
> records.append(strData.split("\n"))
strData.split('\n') is a list of lines. append adds one element to a
list -- in this case the list of lines. You apparently want .extend()
> print "records '%s'" % records
> === end snippet ====
> at this point the output looks like this
>
> '[['this is line 1', 'this is line 2', 'this is line 3', '' ]]'
right, as you requested, even if not what you meant ;-)
Terry J. Reedy
More information about the Python-list
mailing list