ConfigParser is a Python module for reading and writing configuration files that have a structure similar to those of INI files in Microsoft Windows.
Questions tagged [configparser]
683 questions
2
votes
1 answer
How to get configuration file path with configparser object
The code below initiates the conf variable which is an instance of the Configuration class which inherits from ConfigParser.
In its __init__ method it reads the config_file and stores its configuration context in a memory. How can I get a file path…

alphanumeric
- 17,967
- 64
- 244
- 392
2
votes
1 answer
Placement of config file reading
I'm developing a CLI python program and I'm using ConfigParser. I know this is probably more to preference than anything else, but currently my configuration reading script is in config.py in a package. Would I be better off placing my configuration…

sensae
- 493
- 3
- 12
2
votes
4 answers
No module named "backport.configparser"
I have installed configparser using "pip install configparser" to get configparser-3.5.0, and is on my PYTHONPATH. But when i use it as "import configparser", i am seeing an error "No module named backports.configparser". conigparser.py use this…

user3339691
- 455
- 2
- 5
- 16
2
votes
2 answers
ConfigParser removes quotes from empty values
I have an INI windows file with the following format:
[STRINGS]
property 1 = "hello"
property 2 = ""
PROPERTY 3 = ""
but if I get values using ConfigParser
init_values= ConfigParser.RawConfigParser(allow_no_value=True)
init_values.optionxform =…

togarha
- 163
- 3
- 12
2
votes
1 answer
Centos Python 3: ConfigParser using environment variables and cross references
When I try to get the values using ConfigParser,
I am not able to get certain values from environment variables in my .ini file
Interpolating variable names are printing variables as it is without value substitution.
Below is my…

Ashwin
- 993
- 1
- 16
- 41
2
votes
1 answer
Should user data be stored in a config file?
I'm developing a CLI for a web todolist service. I'm done with the backend and have just started to write the CLI functions. Before I start, I tought what the best way was to store user data. I'm using ConfigParser for storing user specified…

Fatih Arslan
- 16,499
- 9
- 54
- 55
2
votes
3 answers
How do I put a semicolon in a value in Python configparser?
I need to specify a password on the right side of the equals sign in a Python configparser file, but semicolon is the comment character.
Escaping with \ does not work.
How can I pass the string "foo;" as a value in configparser?

Daniel
- 2,032
- 5
- 21
- 27
2
votes
1 answer
Modify parameter values of sections in INI files Python
I have a .ini file which I want to modify a particular section.
So for example,
[Section1]
Param1: Hello
Param2: World
[Section2]
fontsize = 10
[Section3]
integers = 971 508 1076 561
I want to modify the integers in section 3 and replace them…

Raghavendra MG
- 89
- 2
- 11
2
votes
1 answer
SafeConfigParser.read() with file object instead of string
I'm using Click to pass in an argument that is a file name. This file name is meant to be used by ConfigParser.SafeConfigParser.read() to read an ini file. Unfortunately, Click passes in a file object which read() cannot handle.
Is there a way to…

orange
- 7,755
- 14
- 75
- 139
2
votes
1 answer
ConfigParser get all keys with duplicates
ini file:
[main]
key_1=1
key_2=2
key_1=3
Python:
config_parser = ConfigParser()
config_parser.optionxform = str
config_parser.read('config.ini')
for section in config_parser.sections():
for key in dict(config_parser.items(section)):
…

oleksii
- 1,367
- 2
- 10
- 11
2
votes
0 answers
ConfigParser.NoSectionError: No section: 'options'
I tried to read a config file of odoo 8 but getting this error:
My config file looks like:
[options]
#This is the password that allows database operations:
admin_passwd = admin
db_host = False
db_port = False
db_user = kabeer
db_password =…

KbiR
- 4,047
- 6
- 37
- 103
2
votes
1 answer
SafeConfigParser: sections and environment variables
(Using Python 3.4.3)
I want to use environment variables in my config file and I read that I should use SafeConfigParser with os.environ as parameter to achieve it.
[test]
mytest = %(HOME)s/.config/my_folder
Since I need to get all the options in a…

Eduardo Fernandes
- 209
- 2
- 10
2
votes
1 answer
Kivy- Packaging to Windows fails: "No module named ConfigParser"
I am trying to package a kivy application for Windows, and after following the instructions in the Kivy website for the example TouchTracer app, I get an ImportError: No Module named ConfigParser message when trying to open the .exe file in the dist…

Alan Casallas
- 31
- 4
2
votes
2 answers
how to interpolate the section-name with configparser
I'm using configparser to read configuration for a backup-system.
one of the options (the output path) often includes the section-name…

umläute
- 28,885
- 9
- 68
- 122
2
votes
1 answer
Nicely parsing a multiline config file in python
I need a config file to generate my scripts.
[PATHS]
elements = elementA,elementB,elementC,elementD,elementE,elementF,elementG,elementH,elementJ,elementK
As you notice after a point the line gets too long. I can not keep track of the elements…

Kristof Pal
- 966
- 4
- 12
- 28