import argparse
import json
arg = argparse.ArgumentParser()
arg.add_argument("-c", "--conf", required=True, help="path to the JSON configuration file")
args = vars(arg.parse_args())
conf = json.load(open(args["conf"]))
Where configuration file is config.json
:
{
"access_token": "Abnmdfjkfe$5",
"base_path": "home"
}
How to use conf
variable:
token = conf["access_token"]
path = conf["base_path"]