Skip to content

Instantly share code, notes, and snippets.

@vtsatskin
Last active December 30, 2015 16:09
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 vtsatskin/7853248 to your computer and use it in GitHub Desktop.
Save vtsatskin/7853248 to your computer and use it in GitHub Desktop.
Python global and user config variables + git. The idea behind this is that you have one central place to keep config variables with the option of having user-specific variables outside of user control. Useful for working with API keys and other sensitive data. Simply put user-specific variables in config_user.py.
config_user.py
secretKey = ""
try:
from config_user import *
except ImportError:
pass # Could not find user config
# Contains user-specific config variables
secretKey = "MY SUPER SECRET KEY"
import config
print "The secret key is: " + config.secretKey
@mylestan
Copy link

mylestan commented Dec 8, 2013

Great, thanks Val! Is there a reason you put the import functionality in config.py, as opposed to in main.py?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment