Author xda@abalgo.com
Recipients xda@abalgo.com
Date 2018-12-17.09:04:27
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1545037468.26.0.788709270274.issue35515@psf.upfronthosting.co.za>
In-reply-to
Content
It seems that the definition of a matrix like this:
a=[[0,0]]*4
does not create the matrix correctly by create 4 times the same pointer.
After the matrix creation, a
print(a)
gives the following result:
[[0, 0], [0, 0], [0, 0], [0, 0]]
which looks normal
print(type(a)) and print(type(a[1]) give also the correct result:
list

But when we try to change a matrix element:
a[2][0]=1
print(a)
gives a false result:
[[1, 0], [1, 0], [1, 0], [1, 0]]

When the matrix definition is done like this:
a=[[0, 0], [0, 0], [0, 0], [0, 0]]
the behavior is "as expected"
a[2][0]=1
print(a)
gives the correct result:
[[0, 0], [0, 0], [1, 0], [0, 0]]
History
Date User Action Args
2018-12-17 09:04:28xda@abalgo.comsetrecipients: + xda@abalgo.com
2018-12-17 09:04:28xda@abalgo.comsetmessageid: <1545037468.26.0.788709270274.issue35515@psf.upfronthosting.co.za>
2018-12-17 09:04:28xda@abalgo.comlinkissue35515 messages
2018-12-17 09:04:27xda@abalgo.comcreate