Monday, April 23, 2012

Get ConfigObj to quote strings

If I run the following script:



from configobj import ConfigObj
config = ConfigObj()
config.filename = 'test.cfg'
config['keyword1'] = "the value"
config['keyword2'] = "'{0:s}'".format("the value")
config['keyword3'] = '"{0:s}"'.format("the value")
config.write()


the output is:



keyword1 = the value
keyword2 = "'the value'"
keyword3 = '"the value"'


Is there any way to produce the following output?



keyword1 = 'the value'




No comments:

Post a Comment