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 do you include complex/imaginary values in config (*.toml, *.ini) files?
I'm migrating my project configurations into a separate config file so that different parts of my project can access them independently. I've been using *.toml files for this lately and I quite like them.
In this project, for the first time, I have…

Drphoton
- 164
- 9
2
votes
1 answer
Map ConfigParser dictionary to a class constructor with correct value types
I have a config ini file which looks like below:
[user]
name=john
sex=male
age=19
income=2345.99
And I have a Python class called User with __init__ constructor below:
class User:
def __init__(self, name: str, sex: str, age: int, income:…

user2150279
- 445
- 2
- 8
- 17
2
votes
1 answer
How to use the writerow function in Python
Im using csv to write rows to an empty text file, but when I open the textfile I see there is a space between each letter/character. I have no idea what I'm doing wrong.
This is my code:
import csv
import configparser
# Read local `config.ini`…

Mediterráneo
- 115
- 1
- 9
2
votes
2 answers
passing a configparser.ConfigParser() object via __init__?
i'm currently working on a project for dns-enumeration, which sends requests to various APIs.
Some of these APIs require an API-Key, which i provide in a config.ini file. In my current setup I use configparser to read-in the different values into an…

Kokaninchen
- 53
- 7
2
votes
2 answers
configparser reading and writing
I'm using Python 3.2 and the configparser module, and running into some problems. I need to read, then write to a config file. I tried the following:
import configparser
data = open('data.txt', 'r+')
a =…

Hypercube
- 1,181
- 2
- 10
- 16
2
votes
2 answers
How to raise exception instead of returning None in Python "ConfigParser" section?
I have a problem using the configparser module.
import configparser
config = configparser.ConfigParser()
config.read_dict({"foo": {}})
foo = config["foo"]
foo.getboolean("missing_field")
I would like my code to raise an exception if the parsed…

Delgan
- 18,571
- 11
- 90
- 141
2
votes
1 answer
Python - How to read list values from config file (INI) using python configParser
i am trying to read some header values from config file in python while creating CSV.
Working Python file:
headers = ['Column1','Column2','Column3']
...
writer.writerow(header)
...
Using Config:
text.conf
[CSV]
headers =…

Satscreate
- 495
- 12
- 38
2
votes
2 answers
ConfigParser options with % in value
I'm trying to parse a .conf file with ConfigParser, and some of the values have a '%' in the value.
Example of the config below:
[global]
workgroup = WORKGROUP
server string = %h server (Samba, Ubuntu)
When I parse this using…

cclloyd
- 8,171
- 16
- 57
- 104
2
votes
3 answers
Python ini parser
Is there a parser which reads and stores the types of data to write?
File format must to produce a readable.
Shelve does not offer.

Evgeny
- 31
- 1
- 3
2
votes
0 answers
ConfigParser with Custom Dict Type
I need to create a custom ConfigParser which adds a few features including, most relevantly here, a default value for unset keys of None. This seems to be supported through custom dict types and accordingly I wrote something like this:
class…

CarlEdman
- 398
- 2
- 14
2
votes
2 answers
ConfigParser raise KeyError(key) Python 3.8
i am trying to make a config file using ConfigParser in python 3.
I get this error when trying to run the script
C:\Users\Deagan>"C:\Users\Deagan\Desktop\Hypixel Rich Presence\Main.py"
Traceback (most recent call last):
File…

Deagan Muir
- 103
- 4
- 13
2
votes
1 answer
nodejs read .ini config file
I have a config file. It has variables stored in the following manner.
[general]
webapp=/var/www
data=/home/data
[env]
WEBAPP_DEPLOY=${general:webapp}/storage/deploy
SYSTEM_DEPLOY=${general:data}/deploy
As you can see it has 2 sections general…

Amarjit Singh
- 2,068
- 19
- 52
2
votes
1 answer
How to get rid of configparser.NoOptionError in django
DEBUG = eval(ctx.get(CONFIGSECTION, 'DEBUG'))
# MDM Revert before prod!
# DEBUG=True
TEMPLATE_DEBUG = DEBUG
REDIS_SERVER = ctx.get(CONFIGSECTION, 'REDIS_SERVER')
REDIS_DB = ctx.get(CONFIGSECTION, 'REDIS_DB')
I am getting below error
raise…

Piyush Patil
- 14,512
- 6
- 35
- 54
2
votes
2 answers
I'm getting an invalid syntax error in configparser.py
I'm trying to get the pymysql module working with python3 on a Macintosh. Note that I am a beginning python user who decided to switch from ruby and am trying to build a simple (sigh) database project to drive my learning python.
In a simple (I…

David
- 5,991
- 5
- 33
- 39
2
votes
0 answers
Python configparser automatically convert to bools
I am writing a class to parse various config files. It contains methods for yaml files and ini + cfg files.
Parsing yamls works fine, but I have a problem with those two other ones. Basically I read them, I parse them, but if e.g. my config.cfg…

dabljues
- 1,663
- 3
- 14
- 30