Using Python 3.5 and ConfigParser.
I want to use a config file like this:
[Section]
key1
key2
key3
i.e. no values. By default ConfigParser requires values but I can pass allow_no_values=True
to the constructor to handle that.
However the parser will still try to split on the delimiters which by default are ('=', ':')
. Thus my lines can't include any of them by default. But I don't want to delimit on anything - none of my lines will ever have a value.
Passing delimiters=() or [] or None does not work. If using an empty list it complains that option '' in section 'Section' already exists
while if None I get 'NoneType' is not iterable
.
So is there no way to make sure that splitting never happens ? It does not feel optimal that I have to specify some char that I "hope" will never be used.
You can set delimiters=('\n',)
which in theory means the key/value delimiter is a newline, which will never happen because the line delimiter is also a newline and it seems to take precedence.
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