Python 2.4 and list of dictionary issues

Discussion in 'Python' started by Chris Stevens, Feb 8, 2010.

  1. 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
    Chris Stevens, Feb 8, 2010
    #1
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Ilias Lazaridis
    Replies:
    6
    Views:
    427
    Ilias Lazaridis
    Feb 21, 2006
  2. james_027
    Replies:
    1
    Views:
    307
    Marc 'BlackJack' Rintsch
    Aug 22, 2007
  3. Navkirat Singh
    Replies:
    6
    Views:
    2,967
    Navkirat Singh
    Jul 29, 2010
  4. Chris Rebert
    Replies:
    0
    Views:
    505
    Chris Rebert
    Jul 29, 2010
  5. OW Ghim Siong
    Replies:
    2
    Views:
    382
    Peter Otten
    Nov 30, 2010
Loading...

Share This Page