list of dictionaries

George Thomas george at
Wed Jun 27 23:09:43 CEST 2001

Hi everyone,
As part of a project, I've ended up deciding to use a list of
dictionaries. However, I don't seem to be getting the "expected" results
of the append() operation on the list object. Here's some sample code to
illustrate the problem.

import string

dict_entry = {

a1 = "apples"
a2 = "oranges"
b1 = "bananas"
b2 = "peaches"
c1 = "coconuts"
c2 = "pears"
d1 = "dalmatians"
d2 = "pecans"

sample_list = []
dict_entry['a'] = a1
dict_entry['b'] = b1
dict_entry['c'] = c1
dict_entry['d'] = d1

dict_entry['a'] = a2
dict_entry['b'] = b2
dict_entry['c'] = c2
dict_entry['d'] = d2

It's something subtle or I'm making a stupid mistake somewhere. Either
ways, can someone see what's going on ?
George Thomas

More information about the Python-list mailing list