[issue36450] 3D Array Assignment to all 2D sub-arrays

2019-03-27 Thread John Bachman


Change by John Bachman :


--
versions: +Python 3.7

___
Python tracker 
<https://bugs.python.org/issue36450>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue36450] 3D Array Assignment to all 2D sub-arrays

2019-03-27 Thread John Bachman


New submission from John Bachman :

Tested on Python3.6 on Ubuntu 18.04
The following code snippet produces the wrong results.

Snippet:

M = [[[0] * 2] * 2] * 2 
   
M[0][0][0] = 1  

   
print(M[0][0][0]) # Should be one   
   
print(M[1][0][0]) # Should still be zero 

My output:
1
1

For some reason when you assign to any list inside the 3D matrix, all lists in 
the array are changed, 2D Matrix works but 3D modifies every 2D matrix.

--
components: Interpreter Core
messages: 338963
nosy: John Bachman
priority: normal
severity: normal
status: open
title: 3D Array Assignment to all 2D sub-arrays
type: behavior
versions: Python 3.6

___
Python tracker 
<https://bugs.python.org/issue36450>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com