title: Formatting string in python to form a js function
body: <p>I have a program that uses string returned from another program and ultimately generates a compound string to be used as a javascript formula in selenium javascript execution. I am having problem formatting as below-</p>
  
  <p>First program returns string like <code>"192.235.50.33:3128"+"\n"+"192.235.50.12:3128"</code>
  And it will be concatenated as below to form a js function-</p>
  
  <pre><code>'document.getElementsByTagName('textarea')[0].value="192.235.50.33:3128"+"\n"+"192.235.50.12:3128";'
  </code></pre>
  
  <p>Which will be used as a javascript code in python selenium webdriver as below-</p>
  
  <pre><code>browser.execute_script('document.getElementsByTagName('textarea')[0].value="192.235.50.33:3128"+"\n"+"192.235.50.12:3128";')
  </code></pre>
  
  <p>Finally my question is how to format the js code as mentioned or is there any better method to achieve this caring the context.</p>
  
  <p>N.B. I am with python 2.7 and selenium (2.47.3) in windows 8.</p>