Skip to content

Instantly share code, notes, and snippets.

@idan
Created February 17, 2014 20:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save idan/9058394 to your computer and use it in GitHub Desktop.
Save idan/9058394 to your computer and use it in GitHub Desktop.
from django.core.exceptions import ImproperlyConfigured
def get_env_variable(var_name):
""" Get the environment variable or return an exception """
try:
return os.environ[var_name]
except KeyError:
error_msg = "Set the {} environment variable".format(var_name)
raise ImproperlyConfigured(error_msg)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment