I thought that the set method of ConfigParser module updates the field given, but, it seems that the change remains only in memory and doesn't get into the config file. Is it a normal behaviour?
I have also tried the write method, but what I got was another replicated section which by so far is not what I want.
Here is a specimen which represents what I'm doing:
import sys
import ConfigParser
if __name__=='__main__':
cfg=ConfigParser.ConfigParser()
path='./../whatever.cfg/..'
c=cfg.read(path)
print cfg.get('fan','enabled')
cfg.set('fan','enabled','False')
c=cfg.read(path)
print cfg.get('fan','enabled')
from ConfigParser import SafeConfigParser
parser = SafeConfigParser()
parser.read('properties.ini')
dhana = {'key': 'valu11'}
parser.set('CAMPAIGNS', 'zoho_next_campaign_map', str(dhana))
with open("properties.ini", "w+") as configfile:
parser.write(configfile)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With