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 8631585
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T09:14:20+00:00 2026-06-12T09:14:20+00:00

This is my example script: import ConfigParser config = ConfigParser.ConfigParser() config.read(‘conf.ini’) print bool(config.get(‘main’, ‘some_boolean’))

  • 0

This is my example script:

import ConfigParser

config = ConfigParser.ConfigParser()
config.read('conf.ini')

print bool(config.get('main', 'some_boolean'))
print bool(config.get('main', 'some_other_boolean'))

And this is conf.ini:

[main]
some_boolean: yes
some_other_boolean: no

When running the script, it prints True twice. Why? It should be False, as some_other_boolean is set to no.

  • 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-12T09:14:21+00:00Added an answer on June 12, 2026 at 9:14 am

    Use getboolean():

    print config.getboolean('main', 'some_boolean') 
    print config.getboolean('main', 'some_other_boolean')
    

    From the Python manual:

    RawConfigParser.getboolean(section, option)
    

    A convenience method which coerces the option in the specified section to a Boolean value. Note that the accepted values for the option are "1", "yes", "true", and "on", which cause this method to return True, and "0", "no", "false", and "off", which cause it to return False. These string values are checked in a case-insensitive manner. Any other value will cause it to raise ValueError.

    Such as:

    my_bool = config.getboolean('SECTION','IDENTIFIER')
    

    The bool() constructor converts an empty string to False. Non-empty strings are True. bool() doesn’t do anything special for "false", "no", etc.

    >>> bool('false')
    True
    >>> bool('no')
    True
    >>> bool('0')
    True
    >>> bool('')
    False
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This is my example script: import urllib2, re response = urllib2.urlopen('http://domain.tld/file') data = response.read()
I've reduced my problem down to this simple example script: #! /usr/bin/python import hello
so I do this in my script: import json info = json.loads(get_info()) print info
In Jquery Template website they gave this example.( http://api.jquery.com/jQuery.template/ ) <script> var movies =
This would be an example of database table: PHP script should limit query result
I have this script- import lxml from lxml.cssselect import CSSSelector from lxml.etree import fromstring
Following this example, I can list all elements into a pdf file import pyPdf
I received this python script that generates a file checksum: import sys,os if __name__==__main__:
This example uses a StringWriter to hold the serialized data, then calling ToString() gives
This example is simplified a bit, but in my ASP.NET web page in my

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.