python -- question with list.pop(0)

  • Thread starter David Stockwell
  • Start date
D

David Stockwell

Hi,

I'm getting an error 'oops an error pop from an empty list'

However I am printing the contents of the list right before i am attempting
the pop and there are items in the list.

The weird thing is the list looks different than i expect it to be.

code snippet:
--- begin snippet --

ourFile = open(fileNamesList[0],'r')
strData = ourFile.read()
ourFile.close()

records = []

#
# do we need to use \r\n????
#

print "split 0.5"
records.append(strData.split("\n"))
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', '' ]]'

I don't understand why two [[ list symbols are showing up, its like its a
list of lists?

Then when I attempt to pop the first element I get the error.

Probably the problem is somehow related to having [ [ ??

What am I doing wrong?

Thanks


David
-------
Tracfone: http://cellphone.duneram.com/index.html
Cam: http://www.duneram.com/cam/index.html
Tax: http://www.duneram.com/index.html

_________________________________________________________________
Watch the online reality show Mixed Messages with a friend and enter to win
a trip to NY
http://www.msnmessenger-download.click-url.com/go/onm00200497ave/direct/01/
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,787
Messages
2,569,631
Members
45,340
Latest member
Thalia56P0

Latest Threads

Top