newbie : array initialization, anyone ?
Gerson Kurz
gerson.kurz at t-online.de
Wed Dec 27 11:10:02 EST 2000
you can initialize a fixed-size array using something like
array = [0] * 10
now, one would think that you can initialize a multidimensional array
like this:
multidim = [ [0] * 10 ] * 3
but now, all 3 elements in multidim are references to the same single
array, so that if you type
multidim[0][0] = 1
print multidim
you actually get three 1 in all those 0s. Where did my thinking go
wrong along these lines ?
More information about the Python-list
mailing list