Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #91049 > unrolled thread
| Started by | georgeryoung@gmail.com |
|---|---|
| First post | 2015-05-22 09:59 -0700 |
| Last post | 2015-05-22 10:35 -0700 |
| Articles | 3 — 2 participants |
Back to article view | Back to comp.lang.python
case-sensitive configparser without magical interpolation? georgeryoung@gmail.com - 2015-05-22 09:59 -0700
Re: case-sensitive configparser without magical interpolation? Ian Kelly <ian.g.kelly@gmail.com> - 2015-05-22 11:12 -0600
Re: case-sensitive configparser without magical interpolation? georgeryoung@gmail.com - 2015-05-22 10:35 -0700
| From | georgeryoung@gmail.com |
|---|---|
| Date | 2015-05-22 09:59 -0700 |
| Subject | case-sensitive configparser without magical interpolation? |
| Message-ID | <1d76eb69-7880-4a25-976c-96a69b61b91f@googlegroups.com> |
[python 2.7] I need to use a configparser that is case-sensitive for option names, but does not do magical interpolation of percent sign. I.e.: [Mapping0] backupHost = eng%26 dbNode = v_br_node0001 should be read (and later written) as is, including capitalization and the percent sign. I find that RawConfigParser keeps the %, but downcases the option name. And SafeConfigParser can be hacked with optionxform to be case-sensitive, but does interpolation. How can I get case-sensitive but no interpolation? -- George
[toc] | [next] | [standalone]
| From | Ian Kelly <ian.g.kelly@gmail.com> |
|---|---|
| Date | 2015-05-22 11:12 -0600 |
| Message-ID | <mailman.226.1432314781.17265.python-list@python.org> |
| In reply to | #91049 |
On Fri, May 22, 2015 at 10:59 AM, <georgeryoung@gmail.com> wrote: > [python 2.7] > I need to use a configparser that is case-sensitive for option names, but does not do magical interpolation of percent sign. > I.e.: > > [Mapping0] > backupHost = eng%26 > dbNode = v_br_node0001 > > should be read (and later written) as is, including capitalization and the percent sign. > > I find that RawConfigParser keeps the %, but downcases the option name. > And SafeConfigParser can be hacked with optionxform to be case-sensitive, but does interpolation. > How can I get case-sensitive but no interpolation? RawConfigParser also has the optionxform method; have you tried overriding that? If that doesn't work, then how strict is the 2.7 requirement? In 3.2 or later, the ConfigParser takes an interpolation keyword argument that can be used to disable interpolation: https://docs.python.org/3.4/library/configparser.html#configparser-objects
[toc] | [prev] | [next] | [standalone]
| From | georgeryoung@gmail.com |
|---|---|
| Date | 2015-05-22 10:35 -0700 |
| Message-ID | <429c3629-5735-4c40-968c-782071f12691@googlegroups.com> |
| In reply to | #91051 |
On Friday, May 22, 2015 at 1:13:39 PM UTC-4, Ian wrote: > On Fri, May 22, 2015 at 10:59 AM, gy wrote: > > [python 2.7] > > I need to use a configparser that is case-sensitive for option names, but does not do magical interpolation of percent sign. > > I.e.: > > > > [Mapping0] > > backupHost = eng%26 > > dbNode = v_br_node0001 > > > > should be read (and later written) as is, including capitalization and the percent sign. > > > > I find that RawConfigParser keeps the %, but downcases the option name. > > And SafeConfigParser can be hacked with optionxform to be case-sensitive, but does interpolation. > > How can I get case-sensitive but no interpolation? > > RawConfigParser also has the optionxform method; have you tried overriding that? > > If that doesn't work, then how strict is the 2.7 requirement? In 3.2 > or later, the ConfigParser takes an interpolation keyword argument > that can be used to disable interpolation: > > https://docs.python.org/3.4/library/configparser.html#configparser-objects That worked perfectly, thanks!
[toc] | [prev] | [standalone]
Back to top | Article view | comp.lang.python
csiph-web