'ConfigParser: Check If variable in Config File exists
I am currently trying to check if my config file has a variable in it. In the documentation I only saw a check for the sections but not a variable inside the section.
Current code:
#!/usr/bin/python3
from configparser import ConfigParser
def ImportConfig(arg):
config_file = ConfigParser()
config_file.read("configFile")
config = config_file[""+arg+""]
If config['variable'] exists:
do something...
arg is the section name that I give my script as a parameter.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
