[issue9421] configparser.ConfigParser's getint, getboolean and getfloat don't accept `vars`
report at bugs.python.org
Thu Jul 29 20:32:49 CEST 2010
New submission from Łukasz Langa <lukasz at langa.pl>:
ConfigParser (and in effect SafeConfigParser) accept `vars` in the `get()` method so one can override values from the section, merge data from different sources or simply state some required keys for interpolation.
`getint()`, `getfloat()` and `getboolean()` don't accept this argument and this is the reason for this issue: for all getters to present a consistent interface.
There is a small design question here however. We have an inheritance model in configparser that goes like this:
RawConfigParser -> ConfigParser -> SafeConfigParser
ConfigParser redefines `get()` for the purposes of interpolation but doesn't touch the other getters. It's good because in terms of implementation, they are just `type()` decoration over `get()` where type is `int`, `float` or `bool`.
The obvious solution would be to add **kwargs to these getters so that regardless of the implementation of the actual `get()`, all possible values are being passed to it. We can then comment in the docstring that for possible values of **kwargs, the user should check the interface of `get()`. Is that good enough?
PS. I have a patch for the proposed design, will attach if there's consensus.
components: Library (Lib)
nosy: georg.brandl, lukasz.langa, michael.foord, pitrou
title: configparser.ConfigParser's getint, getboolean and getfloat don't accept `vars`
versions: Python 3.2
Python tracker <report at bugs.python.org>
More information about the Python-bugs-list