(Assume an instantiated ConfigParser, c, with a loaded file) c.get("DEFAULT", "foo", False, {"foo": "Bar"})
'Bar'
c.get("DEFAULT", "Foo", False, {"Foo": "Bar"})
Traceback (most recent call last):
File "<pyshell#70>", line 1, in ?
c.get("DEFAULT", "Foo", False, {"Foo": "Bar"})
File "C:\Python23\lib\ConfigParser.py", line 513, in get
raise NoOptionError(option, section)
NoOptionError: No option 'foo' in section: 'DEFAULT'
The offending code appears to be as follows (in ConfigParser.py):
def get(self, section, option):
opt = self.optionxform(option)
if section not in self._sections:
if section != DEFAULTSECT:
raise NoSectionError(section)
if opt in self._defaults:
return self._defaults[opt]
else:
raise NoOptionError(option, section)
elif opt in self._sections[section]:
return self._sections[section][opt]
elif opt in self._defaults:
return self._defaults[opt]
else:
raise NoOptionError(option, section)
It uses optionxform on the supplied option, but not on the one in the
defaults dictionary. If you're going to impose a transform then you
have to do it consistently, imho...
c.get("DEFAULT", "Foo", False, {"foo": "Bar"})
'Bar'
The supplied "Foo" gets transformed to "foo" and matches the one in
the defaults dictionary.
Seems a bit counterintuitive to expect that you supply any defaults as
pre-transformed according to your specified optionxform.
I'm not sure if this is also a problem when reading a file, but there
seems to be a related post about this (with no replies!) dating back
to 2000 http://groups.google.com/groups?hl=e...nnrp1.deja.com
I don't have time to look into it now but I'd guess this problem was
resolved in the more obvious location (when reading a file) but
patching of the defaults dictionary case was omitted.
asqui 0 1275 This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Greg Krohn |
last post by:
I'm trying to subclass ConfigParser so I can use a custom __read method (the
custom format doesn't conform to RFC 822) when needed. Needless to say, it's
not working as expected.
In the...
|
by: asqui |
last post by:
(Assume an instantiated ConfigParser, c, with a loaded file)
>>> c.get("DEFAULT", "foo", False, {"foo": "Bar"})
'Bar'
>>> c.get("DEFAULT", "Foo", False, {"Foo": "Bar"})
Traceback (most recent...
|
by: Elliot Temple |
last post by:
Hi I have two questions. Could someone explain to me why Python is
case sensitive? I find that annoying. Also, why aren't there
multiline comments? Would adding them cause a problem of some...
|
by: Neo-LISPer |
last post by:
Hey
Recently, I researched using C++ for game programming and here is what
I found:
C++ game developers spend a lot of their time debugging corrupted
memory. Few, if any, compilers offer...
|
by: Starwiz |
last post by:
I'm a VB.net programmer, and I'm about to start working
with two C++ programmers and teach them .net.
I've decided to use C# in teaching them, since it's
similar enough to VB.net that I can read...
|
by: Jason Tesser |
last post by:
I am converting data from Access into Postgres and ran into an issue
with case sensitivity. Can I write queries in Access that will be case
insensitive without rewriting the queries. So I would...
|
by: Christian Sell |
last post by:
Hello,
I am running into a problem with PGs case sensitivity with regard to column and
table names. I am using program components that require the object names
returned from database metadata...
|
by: pipehappy |
last post by:
Hello everyone:
I came across the module ConfigParser and can use it correctly.
import ConfigParser
fp = open('test.cfg','w+')
config = ConfigParser.ConfigParser()
config.readfp(fp)...
|
by: Anita Potekkat |
last post by:
Hello,
I had a question regarding Case Sensitivity in 10g & 9i.
(1) Does Case Sensitivity in Oracle have to do with data only? Or does it also effect table & column names? For e.g. in a table...
|
by: sweetpotatop |
last post by:
Hi,
I believe my SQL server was configured as Case sensitivity. I have a
number of stored procedures which were moved from a non-Case
sensitivity SQL server. Because of the Case sensitivity, I...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new...
| |