Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8208333
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T09:18:14+00:00 2026-06-07T09:18:14+00:00

I have a config file using configParser : <br> [ section one ]<br> one

  • 0

I have a config file using configParser:

<br>
[ section one ]<br>
one = Y,Z,X <br><br>
[EG 2]<br>
ias = X,Y,Z<br>

My program works fine reading and processing these values.

However some of the sections are going to be quite large. I need a config file that will allow the values to be on a new line, like this:

[EG SECTION]<br>
EG=<br>
item 1 <br>
item 2 <br>
item 3<br>
etc...

In my code I have a simple function that takes a delimiter (or separator) of the values using string.split() obviously now set to comma. I have tried the escape string of \n which does not work.

Does anyone know if this is possible with python’s config parser?
http://docs.python.org/library/configparser.html

# We need to extract data from the config 
def getFromConfig(currentTeam, section, value, delimeter):
    cp = ConfigParser.ConfigParser()
    fileName = getFileName(currentTeam)
    cp.read(fileName)
    try:
        returnedString = cp.get(section, value)
    except: # The config file could be corrupted
        print( "Error reading " + fileName + " configuration file." )
        sys.exit(1) #Stop us from crashing later
    if delimeter != "": # We may not need to split
        returnedList = returnedString.split(delimeter)
    return returnedList

I would use for this:

taskStrings = list(getFromConfig(teamName, "Y","Z",","))
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-07T09:18:16+00:00Added an answer on June 7, 2026 at 9:18 am

    The ConfigParser _read() method’s docstring says:

    Continuations are represented by an embedded newline then leading whitespace.

    Or alternatively (as the version in Python 3 puts it):

    Values can span multiple lines, as long as they are indented deeper than the first line of the value.

    This feature provides a means to split values up and “continue” them across multiple lines. For example, say you had a config file named 'test.ini' which contained:

    [EG SECTION]<br>
    EG=<br>
      item 1<br>
      item 2<br>
      item 3<br>
    

    You could read the value of EG in the EG SECTION into a list with code like this:

    try:
        import ConfigParser as configparser
    except ImportError:  # Python 3
        import configparser
    
    cp = configparser.ConfigParser()
    cp.read('test.ini')
    
    eg = cp.get('EG SECTION', 'EG')
    print(repr(eg))  # -> '\nitem 1\nitem 2\nitem 3'
    
    cleaned = [item for item in eg.strip().split('\n')]
    print(cleaned)  # -> ['item 1', 'item 2', 'item 3']
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a config.cfg which I parse using the python-module ConfigParser. In one section
I have a python class which reads a config file using ConfigParser: Config file:
I have an project csproj, with app.config file, and logging Ent.Library section using configsource
I have some trouble reading from an ini file using boost program options. The
I have a config file that I read using the RawConfigParser in the standard
I am using php and mysql. I have a Database config file (db-config.php) which
I'm using an XML config file to populate my navigation using Zend_Navigation. I have
I have one custom config file. <Students> <student> <Detail Name=abc Class=1st Year> <add key=Main
I have a config.php file for one of my site which holds information needed
I have a config file that contains the following line: pre_args='$REGION','xyz',3 Using perl from

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.