![](/static/253f0d9b/assets/icons/icon-96x96.png)
![](https://programming.dev/pictrs/image/1d99f7cb-50e7-4994-94c4-fd23f30209b7.png)
If things are changing a bit each month, then in your module rather than a plain variable assignment
darabase = ...
you might want a function that you can pass in parameters to represent the things that can change:
def database(dir, ...):
...
return ...
Then you can call it like this:
from database import database
db = database("/some/path")
… gope that makes some sense.
The “why” is that the import system is caching modules in
sys.modules
.The “what to do about it” is “not this”. Use a package layout with explicit names (
p1.generic_name
etc) instead.You can use relative imports under those packages if you prefer (
from .generic_name import ...
).If you want executables on the path look at setup.py or any of the myriad of overlapping modern equivalents that’ll let you specify a command-libe executable to install, then
pip install -e .
to install it in your venv’s bin dir.