I can do this in python via the ConfigParser module, but it will strip all comments when writing the modified file (which is kind of obvious and I was expecting it to happen), this is undesirable