I’d like to separate dev/test/prod environments :) so let’s see the real example.
Developers, DevOps Engineers, and SysAdmins.
- Put configs in a simple format (JSON, YAML, …)
- Hide unnecessary config information from other envs
I will put my configs in “etc” folder in the root of the project:
Then specify the current env inside “config.yml”, this is my config.yml file content:
Now I want to read the redis configuration from “config-dev.yml”:
It’s time to read these values inside python, this is my “config.py” file:
Now we need to load our config loader once then use it anywhere we like, add these lines to you main module:
The final word
The only issue is that you can not change the structure of “config.yml”, and the other files structures just depend on you.