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
2 answers
Python - list from text file
I am struggling to return a list from a text file, and append new user input values to the list without appending existing values also.
I am using the list in a tkinter combobox, allowing users to type new values to be added to the list. My current…

Justin Hill
- 146
- 12
0
votes
0 answers
Defining multiple options for a key in python configparser
What's the best way to define the possible values a parameter/argument may have? Given the config file below, I'm defining the value 'a' for the method argument. Is it possible to define that the other possible options would be 'b' or 'c' without…

dter
- 1,065
- 2
- 11
- 22
0
votes
1 answer
Mocking Files In Python Unittest In Imported Modules
I readily admit to going a bit overboard with unit testing.
While I have passing tests, I find my solution to be inelegant, and I'm curious if anyone has a cleaner solution.
The class being tested:
class Config():
def __init__(self):
…

Jordon Birk
- 480
- 1
- 9
- 28
0
votes
4 answers
Python write b'xxxx' to config and read it
i have encrypted a password and the result is like this: b'&Ti\xcfK\x15\xe2\x19\x0c'
i want to save it to an config file and reload it
so i can decrypt it and i can use it again as password

bhmth
- 51
- 6
0
votes
0 answers
Python3 \t is printed in text instead of actually doing tab
I've been trying to get a Python 3 script be able to write intention from a config with settings using multi lines. Instead of printing the indent it instead print everything in plane text.
[DEFAULT]
FooParam =
Line1
\tLine2
\tLine3
…

Andreas Broström
- 31
- 3
0
votes
1 answer
Use ConfigParser with different variable types in Python
I am trying to use ConfigParser in the following situation. I am running some code after which i have an object with several attributes. I pick out some of these attributes and write them to a .ini file with configparser. This works fine and my .ini…

R.Meijer
- 3
- 1
- 2
0
votes
1 answer
ConfigParser unintentionally adding extra lines and characters
I'm attempting to use config parser to keep track of some variables that need to get passed between programs. (I'm not sure that this is what ConfigParser is meant for, but it's how the program worked when I got it, so I'm still using it.)…

Shmuelt
- 119
- 8
0
votes
0 answers
How to use information in a serial port config file?
OK. I'm trying to store camera parameters for a cameralink camera in a Python config file, and then pass those parameters on to the camera via a serial port. Does any one know how to do this? This is what I have so far:
Config…

Marco Peterson
- 81
- 1
- 1
- 4
0
votes
2 answers
How to modify python module content?
I have file named config.py, content like below:
logindata = [
{'user': '18320967034', 'password': '123456'}
]
I wanna modify the logindata and write it back,
import config
config.logindata[0]['password'] = 'xxxx'
How can I write it back to…

TreeCatCat
- 143
- 1
- 1
- 12
0
votes
1 answer
Can I use asterisk * in config file variable name?
I am using Config Parser to specify a list of variables, and the values for those variables are then pulled from a larger file. The variables/lines in the larger file all look like this: …

AverageWorker
- 546
- 1
- 4
- 13
0
votes
2 answers
How to read config values from an optional section?
I'm using module configparser in Python 2.7.
In my config file, I want the section log to be optional; my parsing module will provide default values if the section does not exist.
My config file looks like this:
[log]
filename = C:/tmp/myapp.log
Is…

Leonel
- 28,541
- 26
- 76
- 103
0
votes
2 answers
python extract value from config file
I know, there's the famous python config parser, but I think for this kind of config format, the parser will not be the best choice.
"AppState"
{
"appid" "740"
"Universe" "1"
"name" "Counter-Strike Global Offensive -…

kreishna
- 31
- 5
0
votes
1 answer
Python script to parse a config file
Newbie to python here. I'm in need of adding back end and front ends servers to the haproxy.cfg file and do a graceful reload via a python script. Could some of you point me in the right direction. If you include comments in the code it will…

bindo
- 87
- 3
- 18
0
votes
0 answers
How to generate .ini file only contain value?
Could python configparser module generate .ini file as follows:
sample (this entire line written to outfiles)
other comments (this entire line discarded)
IOFILES Keyword, don't edit this line
tset.txt …

Cobin
- 888
- 13
- 25
0
votes
0 answers
Getting all the values under a section in config file using Python
I want to get all the fields under a Section in a config file into a list. Problem with ConfigParser is, it does not allow duplication of Options.Is it possible to use ConfigParser to do so or do I need to read the whole file and put the fields of a…

Ron
- 51
- 1
- 1
- 5