Imagine this situation :
I have a file named settings.py that contains
from datetime import datetime
FOO = datetime.now()
Now, in another file, I do from django.conf import settings
(the fact that I'm using Django in this specific situation is irrelevant)
In the file I did the import when I use settings.FOO
, no matter how much time has passed I will always get the same datetime value, which corresponds to the time when the import happened.
I understand how and why it works that way. My question is : Is there a way to always have an updated value "stored" in settings.FOO
without changing the way I access that value ? (as settings.FOO
is used in multiple file across multiple subprojects, I aim to keep that syntax)
In other words, I there a way to make my imported variable transparently call a function ?