Re: Lists & "pointers"

2005-07-23 Thread Steven D'Aprano
On Sat, 23 Jul 2005 17:03:08 +0200, Jan Danielsson wrote: > The problem is that I have initialized the list like this: > > self.drawAttr = { blah, blah, blah.. } > self.storedAttr = [ ] > for i in range(0, 10): >self.storedAttr.append(self.drawAttr) > >I know what the problem is; they ar

Re: Lists & "pointers"

2005-07-23 Thread André Malo
* Kay Schluehr wrote: > you might initialize self.storedAttr with empty dicts and fill them > later: > > self.soredAttr = [{}]*10 > for entry in self.storedAttr: > entry.update(self.drawAttr) As a matter of fact, you're doing the same ;-) In [1]: x = [{}] * 10 In [2]: x[0]['a'] = 1 In [3]

Re: Lists & "pointers"

2005-07-23 Thread Kay Schluehr
Jan Danielsson wrote: > Hello all, > >I have written a simple whiteboard application. In my application, I > want to be able to set draw attributes. This part works. I have a > dictionary object which contains stuff like: > self.attr['Pen.Color'] = ... > self.attr['Pen.Thickness'] = ... > >

Re: Lists & "pointers"

2005-07-23 Thread George Sakkis
<[EMAIL PROTECTED]> wrote: > Jan Danielsson wrote: > > Hello all, > > > >I have written a simple whiteboard application. In my application, I > > want to be able to set draw attributes. This part works. I have a > > dictionary object which contains stuff like: > > self.attr['Pen.Color'] = ...

Re: Lists & "pointers"

2005-07-23 Thread [EMAIL PROTECTED]
Jan Danielsson wrote: > Hello all, > >I have written a simple whiteboard application. In my application, I > want to be able to set draw attributes. This part works. I have a > dictionary object which contains stuff like: > self.attr['Pen.Color'] = ... > self.attr['Pen.Thickness'] = ... > >

Lists & "pointers"

2005-07-23 Thread Jan Danielsson
Hello all, I have written a simple whiteboard application. In my application, I want to be able to set draw attributes. This part works. I have a dictionary object which contains stuff like: self.attr['Pen.Color'] = ... self.attr['Pen.Thickness'] = ... Now, the problem is that I want to be