a simple configuration class
-
install pyyaml
pip install pyyaml
-
create config.yml
test: fruit: apple: 10 banana: 4 vegetable: carrot: 3
-
import Configuration
from config import Configuration
-
get properties
config = Configuration() apple = config.getProperty("test.fruit.apple") print(f"apple:{apple}")
-
set properties
config = Configuration() config.setProperty("test.fruit.apple", 50) apple = config.getProperty("test.fruit.apple") print(f"apple:{apple}")
-
create
config_custom.yml
overrideconfig.yml
test: fruit: apple: 30