Created
December 13, 2019 14:57
-
-
Save ddrscott/bfb971845bf09cbb387e007addda5b8c to your computer and use it in GitHub Desktop.
Simple environment variable helper
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
All environment variable access should be performed via this module. | |
- allows tracing of where variables are used | |
- provide sensible defaults | |
- reduce string typos | |
""" | |
import os | |
import sys | |
SIZE = '10' | |
COLOR = 'red' | |
# Magic: Override locals with environment settings | |
for key in dict(locals()): | |
if key in os.environ: | |
setattr(sys.modules[__name__], key, os.getenv(key)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment