Re: dictionary containing a list

2006-10-08 Thread Hendrik van Rooyen
"Fredrik Lundh" <[EMAIL PROTECTED]> wrote: > Steve Holden wrote: > > > One of the fascinating things about c.l.py is that sometimes a questin > > will be posted that makes almost no sense to me, and somebody else will > > casually read the OP's mind, home in on the issue and provide a useful > >

Re: dictionary containing a list

2006-10-08 Thread Ben
I think what you mean is that if you change your list, it is changed somewhere in your dicrionary to. Lists are always copied as pointers, except explicitly told other wise. So a = b = [] makes a and be the same list, and a.append(1) makes b -> [1]. So do something like mydict[mykey] = mylist[:] (

Re: dictionary containing a list

2006-10-07 Thread John Machin
Steve Holden wrote: > John Machin wrote: > > Ben wrote: > > > >>Hello... > >> > >>I have set up a dictionary into whose values I am putting a list. I > >>loop around and around filling my list each time with new values, then > >>dumping this list into the dictionary. Or so I thought... > >> > >>It

Re: dictionary containing a list

2006-10-07 Thread Fredrik Lundh
Steve Holden wrote: > One of the fascinating things about c.l.py is that sometimes a questin > will be posted that makes almost no sense to me, and somebody else will > casually read the OP's mind, home in on the issue and provide a useful > and relevant answer. if the assertions made by some

Re: dictionary containing a list

2006-10-07 Thread Steve Holden
John Machin wrote: > Ben wrote: > >>Hello... >> >>I have set up a dictionary into whose values I am putting a list. I >>loop around and around filling my list each time with new values, then >>dumping this list into the dictionary. Or so I thought... >> >>It would appear that what I am dumping int

Re: dictionary containing a list

2006-10-06 Thread goyatlah
I think what you mean is that if you change your list, it is changed somewhere in your dicrionary to. Lists are always copied as pointers, except explicitly told other wise. So a = b = [] makes a and be the same list, and a.append(1) makes b -> [1]. So do something like mydict[mykey] = mylist[:] (

Re: dictionary containing a list

2006-10-06 Thread hanumizzle
On 6 Oct 2006 14:37:59 -0700, Ben <[EMAIL PROTECTED]> wrote: > Is there a way to acheive what I was attempting ? I have done something > almost identical with classes in a list before, and in that case a new > instance was created for each list entry... Not sure what you're trying to pull off, b

Re: dictionary containing a list

2006-10-06 Thread Bryan Olson
Ben wrote: > I have set up a dictionary into whose values I am putting a list. I > loop around and around filling my list each time with new values, then > dumping this list into the dictionary. Or so I thought... > > It would appear that what I am dumping into the dictionary value is > only a poi

Re: dictionary containing a list

2006-10-06 Thread Ben Finney
"Ben" <[EMAIL PROTECTED]> writes: > I have set up a dictionary into whose values I am putting a list. I > loop around and around filling my list each time with new values, > then dumping this list into the dictionary. Or so I thought... Our crystal balls are notoriously unreliable for viewing pro

Re: dictionary containing a list

2006-10-06 Thread John Machin
Ben wrote: > Hello... > > I have set up a dictionary into whose values I am putting a list. I > loop around and around filling my list each time with new values, then > dumping this list into the dictionary. Or so I thought... > > It would appear that what I am dumping into the dictionary value is

dictionary containing a list

2006-10-06 Thread Ben
Hello... I have set up a dictionary into whose values I am putting a list. I loop around and around filling my list each time with new values, then dumping this list into the dictionary. Or so I thought... It would appear that what I am dumping into the dictionary value is only a pointer to the o