Skip to content

Handling configuration and avoid prompting #6

@StoneyJackson

Description

@StoneyJackson

This program will have to run without prompting for anything. So you'll want a configuration file. Then whoever installs the system will just edit these files.

The easiest way to do this to add a python module for configuration: config.py.

DATA_ROOT = 'path/to/where/we/should/store/data'
GITHUB_ROOT = 'https://api.github.com'
GITHUB_USERNAME = 'Your Username'
GITHUB_PASSWORD = 'Your Password'

The problem (as you have discovered) is that this file contains information that we don't want stored in our repository. So store a file called config-example.py with sample and default definitions (like the example above), and then add instructions in README.md to copy this file to config.py and update config.py with appropriate values. Now you can tell git to ignore config.py while keeping config-example.py, by adding the following to a .gitignore file:

config.py

To use these values in your program, just import config and use the values.

## filename: main.py
import config
credentials = (config.GITHUB_USERNAME, config.GITHUB_PASSWORD)

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions