prime
prime

Reputation: 67

parsing a config.ini file in python

so I have a config.ini file which I have to parse and use in my python script, I basically need to run a loop to get the REPOS_TO_CHECK in my script, can anyone help out in how to parse the file and run it in a loop in my script to get the REPOS_TO_CHECK parameters. Thanks.

GITHUB_URL = 'https://api.github.com'
GITHUB_ACCESS_TOKEN = 'xxx'
REPOS_TO_CHECK = [
    ('org1', 'repo1'),
    ('org2', 'repo2'),]

Upvotes: 0

Views: 1046

Answers (1)

Nikola Jankovic
Nikola Jankovic

Reputation: 987

Use the configparser library.

import configparser
config = configparser.ConfigParser()
config.read('config.ini')

Upvotes: 3

Related Questions