Skip to content

Instantly share code, notes, and snippets.

@moozer
Created June 9, 2018 22:40
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 moozer/1e6c324ca52771999553dd70b415294a to your computer and use it in GitHub Desktop.
Save moozer/1e6c324ca52771999553dd70b415294a to your computer and use it in GitHub Desktop.
Example of using yaml file as config file
# if not installed, use
# apt-get install python3-yaml
# or
# pip3 install python-yaml
import yaml
def read_config( filename ):
with open(filename, 'r') as f:
return yaml.load(f)
if __name__ == "__main__":
configfile = "myconfig.yml"
print( "reading from {}".format(configfile) )
config = read_config( configfile )
print( config )
size: 8
count: 15
secret_code: P@ssw0rd
aliases:
- Mister T
- Victim 47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment