すっかり忘れてたがこんなのです。
shallow = [[1,2,3]] * 3 shallow[1][1] = 0 shallow # [[1, 0, 3], [1, 0, 3], [1, 0, 3]] deep = [[1,2,3 ] for f in [1,2,3]] deep[1][1] = 0 deep # [[1, 2, 3], [1, 0, 3], [1, 2, 3]]
という備忘録
すっかり忘れてたがこんなのです。
shallow = [[1,2,3]] * 3 shallow[1][1] = 0 shallow # [[1, 0, 3], [1, 0, 3], [1, 0, 3]] deep = [[1,2,3 ] for f in [1,2,3]] deep[1][1] = 0 deep # [[1, 2, 3], [1, 0, 3], [1, 2, 3]]
という備忘録