Python 2.4 and list of dictionary issues

C

Chris Stevens

Hi all,

I'm a python newbie so please excuse me if I am missing something
simple here. I am writing a script which requires a list of
dictionaries (originally a dictionary of dictionaries, but I changed
it to a list to try and overcome the below problem).

Now my understanding is that you create the empty list, then append or
add entries to it. Correct?

Here is some code:

userInfo = []
....
userInfo.append( {
'username' : uidString[0],
...
'failedattempts' : int(0)
})

I'm not to sure on the bracketing here, but I have tried many
combinations. The issue here is that I get a "IndexError: list index
out of range" message on the line "userInfo.append( {"

I wrote this script on a box with Python 2.6 and it worked fine.
Moving it to a box with 2.4, and I get this error. I can't understand
why i'm getting a list index out of range error when trying to append
(not reference) a list?? I have also tried "+=", and
userInfo(len(userInfo))= .... just get the same error.

Could anyone shed some light on this?

Thanks,
Chris
 

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,755
Messages
2,569,534
Members
45,007
Latest member
obedient dusk

Latest Threads

Top