On 2017-02-21 00:04, Peter Otten wrote:
> Tim Chase wrote:
>> On 2017-02-20 10:45, Peter Otten wrote:
>>> value = parser.get("section-1", "option-1", fallback="default
>>> value")
>>
>> Huh. Do you remember when this was added?
>
> I don't use configparser regularly, so I had to look around myse
Tim Chase wrote:
> On 2017-02-20 10:45, Peter Otten wrote:
>> value = parser.get("section-1", "option-1", fallback="default
>> value")
>
> Huh. Do you remember when this was added? I see it in the 3.x docs,
> but not the 2.x docs. I remember writing my own wrappers multiple
> times for exactly
On 2017-02-20 10:45, Peter Otten wrote:
> value = parser.get("section-1", "option-1", fallback="default
> value")
Huh. Do you remember when this was added? I see it in the 3.x docs,
but not the 2.x docs. I remember writing my own wrappers multiple
times for exactly these purposes, even to the
On 02/20/2017 03:45 AM, Peter Otten wrote:
You can provide a default value in your code with
parser = configparser.ConfigParser()
parser.read(configfile)
value = parser.get("section-1", "option-1", fallback="default value")
Perfect. Thank you!
--
=
On 02/20/2017 01:39 AM, Ben Finney wrote:
I think you misinderstand the semantics of what ‘configparser’ expects
https://docs.python.org/3/library/configparser.html#configparser-objects>:
You are absolutely correct. Thank you!
--
===
Ian Pilcher wrote:
> I am trying to use ConfigParser for the first time (while also writing
> my first quasi-serious Python program). Assume that I want to parse a
> a configuration file of the following form:
>
>[section-1]
>option-1 = value1
>option-2 = value2
>
>[section-2]
>
Ian Pilcher writes:
> How do a set a default for option-1 *only* in section-1?
I think you misinderstand the semantics of what ‘configparser’ expects
https://docs.python.org/3/library/configparser.html#configparser-objects>:
Default values […] are used in interpolation if an option used is
I am trying to use ConfigParser for the first time (while also writing
my first quasi-serious Python program). Assume that I want to parse a
a configuration file of the following form:
[section-1]
option-1 = value1
option-2 = value2
[section-2]
option-1 = value3
option-2 = value4
H