How variables work in python? I tried understand it by assigning a value to a variable(a) and checking memory address of it.But,when I changed the value of that variable(a),I got another memory address.what is the reason for that? and that memory address is in the stack area of the memory? and the scope of it?,when I call del a,only variable identifier('a') was deleted.but,It is still on the memory.After,I call id(3),then,that memory address in the code section of the memory?and how python variables stored in memory?,anyone can explain more?
Code:
#!/usr/bin/python3
import _ctypes
a=45
s=id(a)
print(s)
a=a+2
d=id(a)
print(d)
print(_ctypes.PyObj_FromPtr(s))
del a
print(_ctypes.PyObj_FromPtr(d))
print(id(3))
Output:
10915904
10915968
45
47
10914560