Is there a way for a value from a config file to contain empty lines?
--------------------------------------------------
Rise to the top 3% as a developer or hire one of them at Toptal: https://topt.al/25cXVn
--------------------------------------------------
Music by Eric Matyas
https://www.soundimage.org
Track title: Mysterious Puzzle
--
Chapters
00:00 Is There A Way For A Value From A Config File To Contain Empty Lines?
00:49 Answer 1 Score 0
01:03 Accepted Answer Score 0
01:26 Thank you
--
Full question
https://stackoverflow.com/questions/1432...
--
Content licensed under CC BY-SA
https://meta.stackexchange.com/help/lice...
--
Tags
#python
#avk47
Rise to the top 3% as a developer or hire one of them at Toptal: https://topt.al/25cXVn
--------------------------------------------------
Music by Eric Matyas
https://www.soundimage.org
Track title: Mysterious Puzzle
--
Chapters
00:00 Is There A Way For A Value From A Config File To Contain Empty Lines?
00:49 Answer 1 Score 0
01:03 Accepted Answer Score 0
01:26 Thank you
--
Full question
https://stackoverflow.com/questions/1432...
--
Content licensed under CC BY-SA
https://meta.stackexchange.com/help/lice...
--
Tags
#python
#avk47
ANSWER 1
Score 0
\n is the escape code for a newline. Try using those instead.
ACCEPTED ANSWER
Score 0
The get interface provides substitutions that can be used for a suboptimal work around to the parser's strict handling of new lines:
> cat test.cfg
[test]
test=one%(nl)stwo%(nl)sthree
> cat test.py
import ConfigParser
c = ConfigParser.SafeConfigParser()
c.read('test.cfg')
print c.get('test','test', vars={"nl":"\n\n"})
> python test.py
one
two
three