Can't create list of dictionaries

sophie_newbie paulgeeleher at
Fri Apr 10 13:49:12 CEST 2009

Scratch everything I said, copy() does work. Made a wee mistake
somewhere else.

Apologies if I've wasted anyones time!

On Apr 10, 12:36 pm, sophie_newbie <paulgeele... at> wrote:
> Hi there,
> I've got a function that returns a dictionary, I need to loop and
> return 1000 dictionaries and append them to a list, but the thing is
> that when I do the list.append(funtThatReturnsDict()) the resulting
> only ever has 1 dictionary attached to it, even after running the
> append function 1000 times!
> I've tried using dict.copy() on the dictionary that was returned from
> the function but this didn't work either.
> And the function is definately returning different dictionaries each
> time as I can see that when I print them.
> I know this is something to do with the dictionries being stored as
> references but I've no idea how to fix it seeing as the copy()
> function didn't work.
> Thanks!

More information about the Python-list mailing list