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
Python - Sikuli - ConfigParser.NoSectionError
This is my code:
import ConfigParser
configuration = ConfigParser.ConfigParser()
configuration.read('timesheetconfig.ini')
username = configuration.get('internal','username')
password = configuration.get('internal','password')
url =…

Oscar Mullin
- 21
- 2
2
votes
2 answers
Python and Pyramid -reading a ini file in python using configparser
I need to read an ini configuration file in Python and the related sample from the related section of the development.ini is below:
[app:main]
use = egg:ePRO
pyramid.reload_templates = true
pyramid.debug_authorization = false
pyramid.debug_notfound…

user1050619
- 19,822
- 85
- 237
- 413
2
votes
1 answer
Align values in an INI file generated using ConfigParser
Below is the INI file i am generating using the ConfigParser:
[Global]
no_of_games =
superconf =
I am trying to generate an INI file with the "=" aligned uniformly as below, how could i achieve this, is there a way in the config parser to align the…

Ram
- 1,115
- 8
- 20
2
votes
1 answer
Python: configparser remembers values from previous files
I'm working on a script which scans a series of config files in different directories to make sure that they have a particular value: In this case, they must have the section MySection, which must have the option Opt1, which must not be equal to 0.…

John Allie
- 245
- 2
- 10
2
votes
1 answer
Empty string not getting written with RawConfigParser
I'm copying sections and options and values from one .ini file to another in order to merge multiple .ini files into one, with RawConfigParser.
In one source .ini I have this and would like it to be copied:
[foo]
bar=""
However, the result I got…

n611x007
- 8,952
- 8
- 59
- 102
2
votes
2 answers
Where does the argparse and ConfigParser string replacement syntax come from?
When specifying help in argparse, I often use strings like %(default)s or %(const)s in the help= argument to display default arguments. The syntax is a bit weird, though: I assume it's left over from the days where python strings were formatted with…

Shep
- 7,990
- 8
- 49
- 71
2
votes
6 answers
Cloudfoundry grizzly keystone with devstack Install: configparser error in keystone.conf
I'm trying to install opnstack grizzly on a fresh ubuntu 12.04 server.
The sript runs fin until it reach this point :
screen -S stack -p key -X stuff 'cd /opt/stack/keystone &&
/opt/stack/keystone/bin/keystone-all --config-file…

Damien
- 21
- 1
- 3
2
votes
2 answers
Assigning a known number of variables in an .ini file using a loop
EDIT - I have managed to find a solution to my problem, answered at the bottom of the page.
I have a .ini file which contains a unknown amount of variables, created by a python script through a IRC interface.
The format of the .ini file is as…

Midareru
- 49
- 1
- 8
2
votes
3 answers
Python ConfigParser module rename a section
How can you rename a section in a ConfigParser object?

bph
- 10,728
- 15
- 60
- 135
2
votes
2 answers
Python 2.7: "unresolved import: ConfigParser"
I recently wrote a Python 2.7 script (using PyDev on Eclipse) that took advantage of the built-in ConfigParser module, and the script works perfectly. But when I exported it and sent it to a colleague, he could not get it to work. He keeps getting…

Danny
- 705
- 1
- 7
- 23
2
votes
0 answers
Why does Groovy think I'm passing an instance of the class from a static method?
I'm new to Groovy, so it's likely I am doing something wrong. I had written a configuration to be taken in by ConfigSlurper. But something goes wrong when I actually try to parse it. My code is as follows:
class CharacterMap {
public static…

WindowsWeenie
- 389
- 1
- 5
- 11
1
vote
1 answer
Is there a version of ConfigParser that deals with files with no section headers?
I have a config file which is mainly used in shell scripts, and therefore has the following format:
# Database parameters (MySQL only for now)
DBHOST=localhost
DATABASE=stuff
DBUSER=mypkguser
DBPASS=zbxhsxhg
# Storage…

JCCyC
- 16,140
- 11
- 48
- 75
1
vote
1 answer
Python - Script execution, locationing errors
Using the ConfigParser module I am attempting to read in a configuration file so I can safely allow users to edit settings for an application and share these configurations between scripts.
This has been working perfectly for the main script.…

Draineh
- 599
- 3
- 11
- 28
1
vote
1 answer
Getting 401 unauthorized status in an API
I was making a POST request in nutritionix API using requests module. In one of the API route which is https://trackapi.nutritionix.com/v2/natural/nutrients, which returns all the necessary details for any food item if we pass json as {"query":…

Subhendu Dash
- 13
- 4
1
vote
1 answer
Why does this function work on macOS and not on Windows?
I have a function that is reading a file with configparser and on Windows I have problems with the file encoding.
This is the function:
def getSetting(name,section):
cpass = configparser.RawConfigParser()
cpass.read('data/settings.data',…

Jack Sparviero
- 13
- 5