Created
March 15, 2017 05:17
-
-
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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