New submission from Arnaud <x...@abalgo.com>:
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]] ---------- components: Interpreter Core files: python_bugreport.py messages: 331955 nosy: x...@abalgo.com priority: normal severity: normal status: open title: Matrix operator star creates a false matrix type: behavior versions: Python 2.7, Python 3.5, Python 3.6 Added file: https://bugs.python.org/file48001/python_bugreport.py _______________________________________ Python tracker <rep...@bugs.python.org> <https://bugs.python.org/issue35515> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com