[EMAIL PROTECTED] wrote: >>>>> is there a better way of creating d?? >>>> a = [[0] * 3 for dummy in xrange(3)] >> Each element of a refers to a distinct array. >> >>> Why not simply [[0]*3]*3 ? >> All three elements of the result refer to the same array. > > ... whereas you reassign all three elements of [0]* 3. > >>>> ((0,)*3,)*3 > ((0, 0, 0), (0, 0, 0), (0, 0, 0)) > > You're safe in this one-- changing [0][0] won't change [1][0], 'cuz > you can't!
A technically correct solution. :) -- http://mail.python.org/mailman/listinfo/python-list