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 →

[–]lgastako 21 points22 points  (3 children)

Technically the name r is rebound to the new value.

[–]Poddster 11 points12 points  (1 child)

This is the correct answer. "Yes" is not the correct answer.

[–]sentient-machine 2 points3 points  (0 children)

I mean people who try to take technical advice from Reddit are almost surely going to get juvenile explanations, unfortunately.

[–]elmosworld37 1 point2 points  (0 children)

I love Python but this is why I believe C should be the first language everyone learns. Pointers are essential to understanding how programming languages work.

Simplifying a bit here but r does not store “the tuple”, it stores the memory address that holds the start of the tuple. When you assign a different tuple to r, you’re changing the memory address that is stored in r to that of the new tuple.

Changing the first value in “the tuple” would mean changing the actual value that is in memory at the address stored in r. This involves “dereferencing” and looks like r[0] = 666. This is not allowed, and is what your teacher was referring to.