a=1
b=a
b += 1
When I increment b by 1, it points to a different location in the memory. Therefore, a will still be 1 while b becomes 2. However when I create my own integer class
class integer:
def __init__(self, integer):
self.integer= integer
and create two integer objects such as
a= integer(1)
b= a
and increment b by 1
b.integer+= 1
b will still point to the same memory location with a and both a and b will be 2.
Why does this happen like that? Since everything is an object in python, shouldn't both case1 and2 behave the same way?