Mats Wichmann wrote:

A fix I use instead is to read the whole 'config.ini' myself,
strip the trailing comments and call
'config.read_string (fixed_lines)' instead.

But is there a simple way for all this?


It's described in the documentation. Recognizing Inline comments is supported, but by default they are disabled, you have to set a prefix when you create your ConfigParser object.

That was not obvious, but much simpler:
 config = configparser.ConfigParser (strict=False, 
inline_comment_prefixes=("#"))
 config.read ("config.ini")

Thanks!

--
--gv
--
https://mail.python.org/mailman3//lists/python-list.python.org

Reply via email to