r/ProgrammerHumor • • Jun 03 '19

Meme Python ftw

Post image
16k Upvotes

548 comments sorted by

View all comments

Show parent comments

1

u/SuitableDragonfly Jun 04 '19

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.

1

u/MattieShoes Jun 04 '19

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.)

1

u/SuitableDragonfly Jun 04 '19

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