Skip to content

Instantly share code, notes, and snippets.

@ddrscott
Created December 13, 2019 14:57
Show Gist options
  • Save ddrscott/bfb971845bf09cbb387e007addda5b8c to your computer and use it in GitHub Desktop.
Save ddrscott/bfb971845bf09cbb387e007addda5b8c to your computer and use it in GitHub Desktop.
Simple environment variable helper
"""
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