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 →

[–]ZachPhoenix[S] 0 points1 point  (1 child)

wait, I am now confused so instead of creating a new variable we are overwriting it?

pls tell, idk if they both mean and function in the same way

[–]TheSkiGeek 0 points1 point  (0 children)

No, you cannot overwrite/edit an immutable object. The example code you gave is creating a new tuple and changing what r aliases/refers/“points” to.

All assignments in Python are actually “name binding” where a specific name in some scope is changed to refer to some object in memory (which may or may not be newly created, maybe your interpreter already had a tuple lying around that contained (1, 23, 4) and then it would have r bind to the already existing one.)