[Tutor] script conversion windows -> linux error
Peter Otten
__peter__ at web.de
Sat Mar 26 14:01:07 CET 2011
Rance Hall wrote:
> On Fri, Mar 25, 2011 at 1:54 PM, Walter Prins <wprins at gmail.com> wrote:
>>
>> On 25 March 2011 18:26, Rance Hall <ranceh at gmail.com> wrote:
>>> config_version = config.get('versions','configver',0)
>>> This line fails under 3.2 Linux with the error message:
>>> TypeError: get() takes exactly 3 positional arguments (4 given)
>>> What could the 4th argument be? I only see three.
>>> This same code worked on python 3.1 under windows.
>>> What am I missing?
> Likely explanation. But I don't think it holds water when compared
> against the configparser documentation.
Speaking of the documentation, I think that
http://docs.python.org/py3k/library/configparser.html#configparser.ConfigParser.get
"""
get(section, option, raw=False[, vars, fallback])
[...]
Changed in version 3.2: Arguments raw, vars and fallback are keyword only to
protect users from trying to use the third argument as the fallback fallback
(especially when using the mapping protocol).
"""
makes it clear that instead of
config.get(section, option, rawflag) # 3.1
you now have to write
config.get(section, option, raw=rawflag) # 3.2
because many people erroneously assumed that the third argument was the
fallback value.
Peter
More information about the Tutor
mailing list