BestConfig
raw JSON → 1.3.6 verified Sat May 09 auth: no python
BestConfig is a Python library for easy project configuration management. It supports loading configuration from YAML, JSON, Python files, environment variables, and CLI arguments. Version 1.3.6 is the latest release.
pip install bestconfig Common errors
error KeyError: 'key' ↓
cause Trying to access a config key that does not exist using attribute syntax.
fix
Use config.get('key', default) or check with 'key' in config
error AttributeError: 'Config' object has no attribute 'some_key' ↓
cause Typo or key not loaded (e.g., file not found or env var missing).
fix
Ensure the key exists in your config files or use .get() to avoid AttributeError
error FileNotFoundError: [Errno 2] No such file 'config.yml' ↓
cause Default config file is missing. BestConfig looks for config.yml, config.json, etc.
fix
Create a config.yml or pass a custom path to Config(file='my_config.yml')
Warnings
gotcha Config raises KeyError if accessing a missing key with attribute syntax. Use .get() with a default to avoid exceptions. ↓
fix Use config.get('missing_key', default='fallback') instead of config.missing_key
deprecated The method Config.get_config() is deprecated in favor of direct attribute access or .get(). ↓
fix Replace config.get_config('key') with config.key or config.get('key')
gotcha Environment variable overrides: Prefix env vars with your app name to avoid conflicts. By default, all env vars are loaded. ↓
fix Set Config(env_prefix='MYAPP_') to only load variables starting with 'MYAPP_'
Imports
- Config wrong
from bestconfig import configcorrectfrom bestconfig import Config
Quickstart
from bestconfig import Config
config = Config()
print(config.get('key', default='default_value'))
print(config.key)