Box
Description
Box provides dot-notation access to nested dictionary items similar to javascript. I've found it to be particularly useful for configuration.
Python is high-level enough that I believe it makes sense to use it for configuration. python-box allows you to access deeply-nested attributes using dot-notation.
config.py
import os
from box import Box
AWS_ACCOUNT = os.getenv("AWS_ACCOUNT", "269242409179")
config = Box(
{
"aws": {
"account": AWS_ACCOUNT,
}
}
)
main.py
from config import config
print(f"{config.aws.account = }")
config.aws.account = '269242409179'
Box: https://pypi.org/project/python-box/
Don't miss what's next. Subscribe to Python Library of the Week: