Created
February 12, 2019 00:12
-
-
Save neomanic/279b9032668450588934e46c2687fa32 to your computer and use it in GitHub Desktop.
Demo of how to save/load some basic config using yaml
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 yaml | |
# store all your config in a dictionary | |
a = dict(setting_int=5, setting_string="string", setting_float=3.141) | |
# change a value | |
a["setting_int"] =-10 | |
# save to file | |
f = open("config.yaml", 'w') | |
f.write(yaml.dump(a)) | |
f.close() | |
# reload it from the same file | |
b = yaml.load(open("config.yaml", 'r')) | |
b["setting_int"] # will print -10 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment