Re: [Tutor] Question if my reasoning is right

2009-08-19 Thread Kent Johnson
On Wed, Aug 19, 2009 at 1:52 AM, Darth Kaboda wrote: > I'm questioning my reason for why the follwoing code doesn't behave as I > thought it would upon first coding a project. > > m = 8 > n = 10 > cb = [[[0, None]] * (n + 1)] * (m + 1) > cb[3][2][0] = 10 > > This last statement causes the every fir

Re: [Tutor] Question if my reasoning is right

2009-08-19 Thread Alan Gauld
"Darth Kaboda" wrote cb = [[[0, None]] * (n + 1)] * (m + 1) cb[3][2][0] = 10 This last statement causes the every first element in the list to update. Is this becuase this method of initializing a list is just a copy Yes exactly. To get around this I'm now doing the folowing: cb = [[[0,N

[Tutor] Question if my reasoning is right

2009-08-18 Thread Darth Kaboda
I'm questioning my reason for why the follwoing code doesn't behave as I thought it would upon first coding a project. m = 8 n = 10 cb = [[[0, None]] * (n + 1)] * (m + 1) cb[3][2][0] = 10 This last statement causes the every first element in the list to update. Is this becuase this metho