Lets say i have a file 'file1.py' Its code is
import time
a = 10
print(id(a))
time.sleep(10)
I have another file say 'file2.py' Its code is
b = 10
print(id(b))
I run the file1.py
and it created an object that is holding value 10
. Now while the code in first file is sleep for 10sec i run the file2.py
and now the question is will the b
will also refer to the same object created in a
or it will create another object for itself.
However the object created in a has not been dead yet.
If both the id(a) != id(b)
then how do python manage to create and separate objects for different files at different locations in memory. Why python is not assigning b
to also refer to the same object created in a
case as both a
and b
are assigned same values.