Skip to content

Instantly share code, notes, and snippets.

@mkaranasou
Last active December 17, 2020 01:41
Show Gist options
  • Save mkaranasou/0eeeae1b65c4e50448f03fec79c826d1 to your computer and use it in GitHub Desktop.
Save mkaranasou/0eeeae1b65c4e50448f03fec79c826d1 to your computer and use it in GitHub Desktop.
Example of using parse_config
# To run this:
# export DB_PASS=very_secret_and_complex
# python use_env_variables_in_config_example.py -c /path/to/yaml
# do stuff with conf, e.g. access the database password like this: conf['database']['DB_PASS']
if __name__ == '__main__':
parser = argparse.ArgumentParser(description='My awesome script')
parser.add_argument(
"-c", "--conf", action="store", dest="conf_file",
help="Path to config file"
)
args = parser.parse_args()
conf = parse_config(path=args.conf_file)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment