Looking at code below we see 2 instances of the same class. While we change a mutable property we actually change it to both instances. I find it tricky. Can anyone explain why does it act like this?
class MyClass:
name: str = None
dic: Dict[str, str] = {}
instance_1 = MyClass()
instance_2 = MyClass()
instance_1.name = ':)'
instance_1.dic['key'] = 'value'
print(instance_2.name) # as expected prints None for immutable type str
print(instance_2.dic['key']) # as unexpected prints value, for mutable type dic