You could use a buffer which behaves like a file:
Python 3 solution
import configparser
import io
s_config = """
[example]
is_real: False
"""
buf = io.StringIO(s_config)
config = configparser.ConfigParser()
config.read_file(buf)
print(config.getboolean('example', 'is_real'))
In Python 2.7, this implementation was correct:
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')
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…