Created
June 9, 2018 22:40
-
-
Save moozer/1e6c324ca52771999553dd70b415294a to your computer and use it in GitHub Desktop.
Example of using yaml file as config file
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
# 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 ) |
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
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