Warning: This page has beta status

Use case

When yo ustart using git repositories and put your code for everyone to see, you don’t want to include passwords, API keys and other information.

So hardcoding it in the code is no-go, then what…

Use config files.

Use the template

Python/yaml

You may find a gist here to help you.

  1. Create a config file in yaml format
  2. Copy read_config(..) to your project
  3. Add a config = read_config(config_filename) in main
  4. Use config as a normal dictionary

Advanced

  • add the config filename to .gitignore in the directory

    This will prevent it from being included in the git repo.

Bash

Here is a gist with an example.

  1. Create a config file using bash syntax.
  2. Copy the CONFIGand Source $CONFIG lines to your project.
  3. Reference the variable you need from the config file.

Further reading

see text above for links.