title: store formatted text in variable python
body: <p>I am trying to write a script file via a Python script</p>
  
  <p>For that I have defined a function to open, write &amp; close file
  <code>def funcToCreateScript(filename,filecontent)</code></p>
  
  <p>I have another function, where I am calling <code>funcToCreateScript</code> and am trying to pass it shell script content through a variable. The problem is when I format the text as below </p>
  
  <pre><code>def createfile():
      var = """#!/bin/sh
               echo ${test}
            """
      funcToCreateScript(filename,var)
  </code></pre>
  
  <p>I get the output of script as -</p>
  
  <pre><code>#!/bin/sh
           echo ${test}
  </code></pre>
  
  <p>So, its taking the function's indentation and writing it accordingly. Is there a way to format it so that it will look like</p>
  
  <pre><code>#!/bin/sh
  echo ${test}
  </code></pre>
  
  <p>e.g. - </p>
  
  <pre><code>def main():
      var = """
          #!/bin/sh
          echo ${test}
          """
      print var
  
  main()
  
   &gt; test.py
  
                  #!/bin/sh
                  echo ${test}
  </code></pre>