Re: strange append

2006-10-02 Thread James Stroud
E.Nurminski wrote (off the list): > the intention was to have > > newx = [1, 2] > res = [[1, 2]] > newx = [1, 3] > res = [[1, 2], [1, 3]] > newx = [1, 4] > res = [[1, 2], [1, 3], [1, 4]] > newx = [1, 5] > res = [[1, 2], [1, 3], [1, 4], [1, 5]] > newx = [1, 6] > res = [[1, 2], [1, 3], [1, 4], [1,

Re: strange append

2006-10-02 Thread Bruno Desthuilliers
E.Nurminski wrote: > Hello to all good people > > I am new to the great Py so am quite puzzled by the following code > > --- > > res = [] > x = [ 1, 1 ] > for i in xrange(0,5): > res.append(x) > x[1] = x[1] + 1 > print "x = ", x > print "res = ", res > >

Re: strange append

2006-10-01 Thread Gary Herron
E.Nurminski wrote: > Hello to all good people > > I am new to the great Py so am quite puzzled by the following code > > --- > > res = [] > x = [ 1, 1 ] > for i in xrange(0,5): > res.append(x) > x[1] = x[1] + 1 > print "x = ", x > print "res = ", res > >

Re: strange append

2006-10-01 Thread James Stroud
E.Nurminski wrote: > Hello to all good people > > I am new to the great Py so am quite puzzled by the following code > > --- > > res = [] > x = [ 1, 1 ] > for i in xrange(0,5): > res.append(x) > x[1] = x[1] + 1 > print "x = ", x > print "res = ", res > >

strange append

2006-10-01 Thread E.Nurminski
Hello to all good people I am new to the great Py so am quite puzzled by the following code --- res = [] x = [ 1, 1 ] for i in xrange(0,5): res.append(x) x[1] = x[1] + 1 print "x = ", x print "res = ", res --- Looks like it puts smth lik