christianmlong + config + python3   1

parsing - Using Python's ConfigParser to read a file without section name - Stack Overflow
n python 3, use itertools.chain() to simulate a section header for read_file().

from configparser import ConfigParser
from itertools import chain

parser = ConfigParser()
with open("foo.conf") as lines:
lines = chain(("[top]",), lines) # This line does the trick.
python  config  parser  ini  section  itertools  python3 
august 2016 by christianmlong

Copy this bookmark: