Python 2.4 and list of dictionary issues

Chris Stevens cjstevens at gmail.com
Mon Feb 8 00:08:33 EST 2010


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



More information about the Python-list mailing list