Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > Python 2.4 and list of dictionary issues

Thread Tools

Python 2.4 and list of dictionary issues

Chris Stevens
Posts: n/a
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?

Reply With Quote

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Memory issues when storing as List of Strings vs List of List OW Ghim Siong Python 2 11-30-2010 12:22 PM
Performance ordered dictionary vs normal dictionary Navkirat Singh Python 6 07-29-2010 10:18 AM
Re: Performance ordered dictionary vs normal dictionary Chris Rebert Python 0 07-29-2010 06:11 AM
creating a dictionary from a dictionary with regex james_027 Python 1 08-22-2007 07:39 AM
[DICTIONARY] - Copy dictionary entries to attributes Ilias Lazaridis Python 6 02-21-2006 11:27 AM