Skip to content

Instantly share code, notes, and snippets.

@neomanic
Created February 12, 2019 00:12
Show Gist options
  • Save neomanic/279b9032668450588934e46c2687fa32 to your computer and use it in GitHub Desktop.
Save neomanic/279b9032668450588934e46c2687fa32 to your computer and use it in GitHub Desktop.
Demo of how to save/load some basic config using yaml
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