1
PROD ="IND"
LOCATION ="NY"
LOLO ="abc"
yaml_content = """
    MAIN :
      PROD : {}
      LOCATION : {}
    EXTRA :
      LOLO : {}
    """.format(PROD, LOCATION, LOLO)
yaml_content = re.sub("\n\s", "\n", yaml_content.strip())
print yaml_content
I have as output in print:
MAIN :
         PROD : IND
         LOCATION : NY
       EXTRA :
         LOLO : abc
There’s space I don’t want! The right way should be:
MAIN :
  PROD : IND
  LOCATION : NY
EXTRA :
  LOLO : abc
Someone knows how to rephrase the re.(...)