0





95

Advertisement

Is it possible to read the configuration for ConfigParser from a string or list?
Without any kind of temporary file on a filesystem

OR
Is there any similar solution for this?

Question author Lucas | Source

Advertisement


0


You could use a buffer which behaves like a file:

import ConfigParser
import StringIO

s_config = """
[example]
is_real: False
"""
buf = StringIO.StringIO(s_config)
config = ConfigParser.ConfigParser()
config.readfp(buf)
print config.getboolean('example', 'is_real')
Answer author Noel-evans