Is this object mutable?
class Clock(object):
def __init__(self, time):
self.time = time
def print_time(self):
print(self.time)
boston_clock = Clock('5:30')
paris_clock = boston_clock
paris_clock.time = '10:30'
boston_clock.print_time()
It prints "10:30" even when I have expected to print "5:30" because strings are unmutable. Compared to code:
a = "Hello"
b = a
b += " World"
print(a)
it prints "Hello". The object Clock behaves as a list so I think it is mutable but I dont know why. And in that case, how can I make the Clock class unmutable?