I have a django application which uses a library.py file :
library.py
a=5
View 1:
import library
print library.a # prints 5
On a certain event after updating the library.py file and change a=10
View 2:
import library
reload(library) # Should refresh library for the entire project
Then I again execute view 1:
It still prints 5, why ?
Can someone explain, since it should have printed 10, since I updated the value and reloaded the library that was in a shared memory for a python manage.py runserver
No, it shouldn’t. It will reload it in current module only. And don’t use it for reloading the code of your project, use the proper way depending on your deployment scheme.