This is my scenario. I have a package that consists of several modules. They all import from settings.py. Some of the variable, though, depend on user input.
...
# some CONSTANTS
...
PROJECT_DIR = Path(os.path.abspath(__file__)).parent.ancestor(1)
SCRIPT_DIR = PROJECT_DIR.child('scripts')
data_input = DATA_ROOT.child('input')
input_root = data_input.child(options.root_input) # the options object holds some user input
# then use input_root to get an instance of class Countries
from countries import Countries
country_object = Countries(input_root)
there are several modules that need the country_object. So importing them from settings would be the cleanest solutions.
So I was reading up on dependency injection and I think this is what comes in handy here. But I find it difficult to wrap my around it so how would one use dependency injection to inject the options object into a module?