I'm trying to understand the difference between references and objects. Please let me know if I'm not using the right terminology.
Consider the following code:
# SCENARIO 1
a = 1
b = a
a = 3
b # still 1, no surprises there
Also consider the following code:
# SCENARIO 2
class Node:
def __init__(self, link, value):
self.link = link
self.value = value
sll = Node(Node(None, 1), 2)
current = sll
current = current.link
current.value = 3
sll.link.value # updated to 3!
I've seen a lot of similarly phrased questions, but I still cannot understand what makes scenarios 1 and 2 different such that in scenario 2 we can update sll by manipulating its reference, but we cannot do the same in scenario 1.