Skip to content

Instantly share code, notes, and snippets.

@modi95
Created March 15, 2017 05:17
Show Gist options
  • Save modi95/a06413767b0368c97b5c19e1be4a32b2 to your computer and use it in GitHub Desktop.
Save modi95/a06413767b0368c97b5c19e1be4a32b2 to your computer and use it in GitHub Desktop.
I was feeling a bit lazy while refactoring config.py to config.yml. Here's a humorous way to get around that issue :D
import ruamel.yaml
CONFIG_FILE_NAME = 'config.yml'
def load_config(globs):
"""Read file and set values. The parameter is intended to be globals()."""
config_dict = yaml.load(open(CONFIG_FILE_NAME, 'r'))
for key in config_dict:
globs[key] = config_dict[key]
load_config(globals())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment