Skip to content

Instantly share code, notes, and snippets.

@mingrammer
Created March 8, 2017 16:02
Show Gist options
  • Save mingrammer/fe4440b750184ff658790ce0cb4d474c to your computer and use it in GitHub Desktop.
Save mingrammer/fe4440b750184ff658790ce0cb4d474c to your computer and use it in GitHub Desktop.
# main_with_ini.py
import configparser
config = configparser.ConfigParser()
config.read('config.ini')
secret_key = config['DEFAULT']['SECRET_KEY'] # 'secret-key-of-myapp'
ci_hook_url = config['CI']['HOOK_URL'] # 'web-hooking-url-from-ci-service'
# main_with_json.py
import json
with open('config.json', 'r') as f:
config = json.load(f)
secret_key = config['DEFAULT']['SECRET_KEY'] # 'secret-key-of-myapp'
ci_hook_url = config['CI']['HOOK_URL'] # 'web-hooking-url-from-ci-service'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment