configparser bug

Christos Malliopoulos cmalliopoulos at gmail.com
Wed Jan 25 01:38:08 EST 2017


Hi,

I run Ubuntu 16.04 LTS in a VM using VMWare Workstation on a Windows 10
host.
apt show python-configparser shows 3.3.0r2-2
On python 2.7.12 I use the following code:

import configparser as cfg
root =
u'/'.join(os.path.split(os.path.abspath('cfg.py'))[0].split('/')[:-2])
cp = cfg.ConfigParser(interpolation = cfg.ExtendedInterpolation())
cp.read(os.path.abspath(os.path.join(root, u'config/sampling.cfg')))

cp.items('Sampling')

sampling.cfg contains the following lines:
[Sampling]
    nobs = 10
    nzin = 4
    nzout = 3
    ndrops = 1

    inh = day,loc,z0,value
    outh = day,loc,sku,value

    invalran = 1,1e3
    outvalran = 1,1000

cp.items(u'Sampling') prints the following:
[(u'nobs', u'10'),
 (u'nzin', u'4'),
 (u'nzout', u'3\nndrops = 1'),
 (u'inh', u'day,loc,z0,value'),
 (u'outh', u'day,loc,sku,value'),
 (u'invalran', u'1,1e3'),
 (u'outvalran', u'1,1000')]

ndrops = 1 is not parsed correctly



More information about the Python-list mailing list