[ python-Bugs-1234965 ] ConfigParser generating strings I can't compare

SourceForge.net noreply at sourceforge.net
Fri Jul 8 22:50:34 CEST 2005


Bugs item #1234965, was opened at 2005-07-08 20:50
Message generated for change (Tracker Item Submitted) made by Item Submitter
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1234965&group_id=5470

Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: Python Library
Group: Python 2.4
Status: Open
Resolution: None
Priority: 5
Submitted By: Robert Guico (lpangelrob)
Assigned to: Nobody/Anonymous (nobody)
Summary: ConfigParser generating strings I can't compare

Initial Comment:
This is better demonstrated than described:

Assume the following "myconfig.cfg" in the current
directory...

[main]
OPT=no
<newline>

The following occurs from the command line:

Python 2.4 (#60, Nov 30 2004, 11:49:19) [MSC v.1310 32
bit (Intel)] on win32
<snip>
>>> from ConfigParser import ConfigParser
>>> p = ConfigParser()
>>> p.read('myconfig.cfg')
['myconfig.cfg']
>>> configWord = p.get('main','OPT')
>>> configWord
'no'
>>> word = 'no'
>>> word
'no'
>>> configWord is word
False
>>> word2 = 'no'
>>> word2
'no'
>>> word2 is word
True
>>> len(word)
2
>>> len(configWord)
2
>>> type(configWord)
<type 'str'>
>>> type(word)
<type 'str'>

In other words, the config values ConfigParser
generates look a lot like strings, have types like
strings, and have the same lengths as strings, but
can't be compared as strings. This smells like a bug.

----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1234965&group_id=5470


More information about the Python-bugs-list mailing list