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
0
votes
1 answer
Using ConfigParser to delete lines in config file with no sections
I am trying to change a .conf file on a Linux server, but there are no sections in the .conf file. I want to search in a key/value pair for a specific keyword and then delete a couple of lines above that line and some lines below that line.
How do…

The Nomad
- 7,155
- 14
- 65
- 100
0
votes
3 answers
Python populate list from a string with separator
I have a string which I am parsing using ConfigParser. This string contains some options for a process to run. I want to construct a List from this…

creativeDrive
- 245
- 1
- 5
- 13
0
votes
1 answer
python gi.repository Notify and new line "\n"
I'm not able to display a new line in 'gi.repository Notification'. It works when i use string constant within a program, but fails when i read string from configuration file using ConfigParser class.
test.ini
[NOTIFICATIONS]
test1 =…

user2772570
- 25
- 1
- 3
0
votes
1 answer
Should I use a ConfigParser directly in my code?
I hope there is a 'right' answer to this:
When using ConfigParser to manage default values in a .cfg or .ini file, should I copy everything I need to program variables and copy them back out on exit, or should I use the config.get(section, option)…

Scruffy
- 908
- 1
- 8
- 21
0
votes
1 answer
How to add multiple sections config parser?
def contador(self):
estado=self.ui.chbL01
lugar=self.ui.lineEdit
global contadorr
if(estado.isChecked()):
contadorr=contadorr+1
self.ui.lineEdit.setText(str(contadorr))
config =…

Nico Sanchez
- 11
- 1
0
votes
1 answer
Python33 - SafeConfigParser putting invisible newline, or is not a valid http.server input
I am making a custom settings file for a webserver, and the settings file looks like this:
[server]
adress = "127.0.0.1"
port = 8080
The code to parse this:
def main():
parser = SafeConfigParser()
parser.read("settings.cfg")
global…

IPDGino
- 706
- 1
- 8
- 17
0
votes
1 answer
configparser : which encoding on windows?
My Python3 project works well on Linux but I got a problem with the configparser module on Windows. Every files of my own are encoded using UTF-8/unicode.
The following code :
CONFIG_INI = configparser.ConfigParser()
CONFIG_INI.read(…

suizokukan
- 1,303
- 4
- 18
- 33
0
votes
2 answers
Python: Check config file
I have made a program that collects and creates data inside config files (.ini) but the thing is I need to know how I can make it so it checks if something is already in the config file and then if it is not in there it will right it into…

Dan Alexander
- 2,004
- 6
- 24
- 34
0
votes
1 answer
python config file error
I have a program that updates information to an ini file but when I try to do this I get this error:
Exception in Tkinter callback
Traceback (most recent call last):
File "C:\Program Files\Python33\lib\tkinter\__init__.py", line 1475, in __call__
…

Dan Alexander
- 2,004
- 6
- 24
- 34
0
votes
1 answer
python configparser writes configuration file to one line
I have a configuration file that I would like to change settings to from a python script. Here is my skeleton code:
config = ConfigParser()
config.read('settings.conf')
config.set("SCRIPT", "SOMEFIELD",…

Richard
- 15,152
- 31
- 85
- 111
0
votes
1 answer
Lock ConfigParser in read-only mode
Is there an attribute to lock a ConfigParser object in read-inly mode ?
I'm using a project-wide global ConfigParser object and I want to prevent the code from modifying the object. I could easily override ConfigParser.set(section,option,value) to…

lucasg
- 10,734
- 4
- 35
- 57
0
votes
1 answer
Check preferences with configparser
I have an application that can be started using some user preferences. To do so, I use the ConfigParser class from the built-in package ConfigParser. I derived a subclass of ConfigParser that implements the __getitem__ and __setitem__ methods in…

Eurydice
- 8,001
- 4
- 24
- 37
0
votes
1 answer
Use Python's ConfigParser to automatically remove options
When using ConfigParser to parse multiple configuration files at the same time, is it possible to have an option from the first file removed by the second, and not just have it's value changed?

Subbarker
- 157
- 2
- 10
0
votes
1 answer
python configparser map section values to other sections
I'd like to be able to read a variable list of files from a config file section and use the keys from that list to point to further sections that define attributes for each file. The files can change in number and name and attributes. Has anyone…

Bill Rosmus
- 2,941
- 7
- 40
- 61
0
votes
1 answer
Is there any way to use ConfigParser to evaluate formulas rather than interpolate strings?
I'm using ConfigParser in python 2.7.5 to parse a configuration file. I would like to interpolate some values but treat them as integers rather than strings (i.e., do the calculations). Is this possible?
Here's how I'm doing it currently:
global…

Crystal
- 137
- 1
- 2
- 7