Polidoro Config it is a configuration manager for you project
Python Versions |
---|
Create a class inheriting from ConfigBase
from pconfig import ConfigBase
class Config(ConfigBase):
DB_HOST = 'localhost'
ENVIRONMENT = 'development'
...
When the class is instantiated will load from environment variables.
# script.py
from pconfig import ConfigBase
class Config(ConfigBase):
MY_VAR = 'default_value'
print(Config.MY_VAR)
>>> python script.py
default_value
>>> MY_VAR="new_value" python script.py
new_value
If you have the python-dotenv
installed will load the .env
automatically.
Also, you can load from a .yaml
file setting the file path in the Config
class:
# script.py
from pconfig import ConfigBase
class Config(ConfigBase):
file_path = "my_config.yml"
MY_VAR = 'default_value'
For more information see the Documentation