Using ChainMap to use configs with precedence

from collections import ChainMap
from pprint import pprint
local_config = {
"user": "localuser",
"pass": "localpass",
"host": "localhost"
}
global_config = {
"user": "globaluser",
"pass": "globalpass",
"host": "globalhost",
"timeout": 15
}
config = ChainMap(local_config, global_config)
pprint(config)
for k,v in config.items():
print(f"{k}:{v}")

AWS and Python developer and Linux enthusiastic.

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

Moving away from Google Chrome

How to Build HTML Forms Right: Styling

What is web 3.0

What everyone should know about Android testing

Run GUI commands in Docker Container

Jenkins & its Use-Case

Liverpool Locks CustomerTestimonial https://t.co/0QWahS5esg

Maximizing CI/CD in Tunaiku Deployment Process

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Martin Koníček

Martin Koníček

AWS and Python developer and Linux enthusiastic.

More from Medium

Building a CI-CD Pipeline with Vercel and GitHub Actions

Q&A with Kaspar&’s Rominga Büchler

8 August 2020

Barry Ritholtz on Masters in Business