Skip to content

Instantly share code, notes, and snippets.

@snanda85
Created July 12, 2012 07:50
Show Gist options
  • Select an option

  • Save snanda85/3096523 to your computer and use it in GitHub Desktop.

Select an option

Save snanda85/3096523 to your computer and use it in GitHub Desktop.
Reading config from a python module instead of a separate configuation format
# config.py
arg1 = 5
arg2 = 6
# utils.py
import config
def read_config(arg, default_value=None):
return getattr(config, arg, default_value)
# myapp.py
from utils import read_config
arg1 = read_config("arg1")
if not arg1:
print "arg1 is mandatory"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment