Variable Scope 2 -- Thanks for 1.
Jens Thiede
jensthiede at webgear.co.za
Sun Jan 11 13:45:40 EST 2004
OK, thanks for sorting that out, but what do I replace in the
following to avoid referancing:
x = [[0]*5]*5
x is [[0,0,0,0,0], [0,0,0,0,0], [0,0,0,0,0], [0,0,0,0,0], [0,0,0,0,0]]
and after
x[0][0] = 1;
x is [[1,0,0,0,0], [1,0,0,0,0], [1,0,0,0,0], [1,0,0,0,0], [1,0,0,0,0]]
is there a shorthand way to avoid referance or do I have to use a loop
or:
x = [[0]*5]+[[0]*5]+[[0]*5]+[[0]*5]+[[0]*5]
which is obviously stupid to try and do when the second cofficiant is
large or a variable.
Help would be much appreciated,
Jens Thiede
More information about the Python-list
mailing list