0

I've been trying to get a Python 3 script be able to write intention from a config with settings using multi lines. Instead of printing the indent it instead print everything in plane text.

[DEFAULT]
FooParam = 
    Line1
    \tLine2
    \tLine3
    Line4

Above example return the following output both as print (FooParam) and as f.writelines (FooParam):

Line1
\tLine2
\tLine3
Line4

I've also tried to make additional spaces and this did not work either.

[DEFAULT]
FooParam = 
    Line1
        Line2
        Line3
    Line4

with the same output;

Line1
Line2
Line3
Line4

The string I use to call the target parameter look like this:

FooParam = cfg.get(make_target, "FooParam", fallback="")

Is there are a way to make tabs being taken in consideration when reading from a config?

poke
  • 369,085
  • 72
  • 557
  • 602
  • 1
    Can you post a small concise code which one can use to reproduce the issue? Hard to debug given the current code – Tarun Lalwani Aug 05 '17 at 15:31
  • The text content is parsed from the INI file literally, so a `\t` has no special meaning there and will be represented as text. Also, the config parser ignores leading and trailing whitespace in text values. – The solution would probably be to either write your own parser, or use a different better-suited file format. – poke Aug 05 '17 at 15:31

0 Answers0