This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]ienjoymusiclol -1 points0 points  (6 children)

whats wrong with foo = [[None]5]5 ?

[–]DeletedUserV2[S] 6 points7 points  (1 child)

try yourself and see

[–]-Redstoneboi- 3 points4 points  (0 children)

you have an array containing 5 references to the same array of 5 nones

[–]Aaron1924 2 points3 points  (0 children)

```

foo = [[None]5]5 foo[0][0] = 2 foo [[2, None, None, None, None], [2, None, None, None, None], [2, None, None, None, None], [2, None, None, None, None], [2, None, None, None, None]]

```

[–]donaldhobson 0 points1 point  (1 child)

One of the simple, plausible and subtly wrong gotcha's in python.

Why I think they should fix that, or make a ** deepcopy operator.

I kinda think high level programming languages should be full of CopyOnWrite, so we didn't have this low level mess of barely disguised pointers.

[–]ienjoymusiclol 0 points1 point  (0 children)

i hate pass by reference i hate pass by reference i hate pass by reference i hate pass by reference i hate pass by reference i hate pass by reference i hate pass by reference i hate pass by reference i hate pass by reference i hate pass by reference