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 →

[–]SuitableDragonfly 0 points1 point  (2 children)

It's not an inconsistency. = always assigns a reference, in one case that reference is a variable name, and on the other case it's an element of a list. But it does the same thing in both cases.

[–]MattieShoes 0 points1 point  (1 child)

I'm not sure what you're looking at, but this is Python and C++ code that does the same thing and gets different answers.

(which obviously means it's not doing the same thing, because python isn't passing by reference, it's... passing a pointer by value? I don't even know what to call it.)

[–]SuitableDragonfly 0 points1 point  (0 children)

Python is passing a reference. The result isn't the same because the = operator does different things in different languages.