2

I'm very new in Python and I need to modify a configuration file. I'm able to do so using configparser but the problem is that I need to keep the comments in the config file and it seems that it is not possible with it. I found Update INI file without removing comments, but the problem is not completely solved.

The apparent solution is to use ConfigObj but the comments say that it's obsolete so I don't want to use this approach.

Pika Supports Ukraine
  • 3,612
  • 10
  • 26
  • 42
  • Maybe a crude approach would be writing some regular expression to modify values. – Andrej Kesely Jul 26 '18 at 15:56
  • @AndrejKesely could you be more specific? – Arturo Rodriguez Jul 26 '18 at 20:49
  • If you need to change simple variable, you could write simple regex for it. It will change only that value and keeps all the comments intact. – Andrej Kesely Jul 26 '18 at 20:51
  • Sorry for replying so late. The thing is that I need to modify a lot of variables, so I don't find this approach useful in my case. Also, you may be wondering why I need the comments, well they're kind of essentials for what I want. Any other idea? Thanks – Arturo Rodriguez Feb 25 '19 at 09:28

0 Answers0