title: Tricky Python string literals in passing parameter to timeit.Timer() function
body: <p>I'm having a hard time with the setup statement in Python's timeit.Timer(stmt, setup_stmt). I appreciate any help to get me out of this tricky problem:</p>
  
  <p>So my sniplet looks like this:</p>
  
  <pre><code>def compare(string1, string2):
      # compare 2 strings
  
  if __name__ = '__main__':
      str1 = "This string has \n several new lines \n in the middle"
      str2 = "This string hasn't any new line, but a single quote ('), in the middle"
  
      t = timeit.Timer('compare(p1, p2)', "from __main__ import compare; p1=%s, p2=%s" % (str1,str2))
  </code></pre>
  
  <p>I don't know how to escape the metacharacter in the variable str1, str2 without changing their meaning in the setup statement: </p>
  
  <pre><code>"from __main__ import compare; p1=%s, p2=%s" % (str1,str2)
  </code></pre>
  
  <p>I tried various combination but always have the following errors:
  SyntaxError: can't assign to literal<br>
  SyntaxError: EOL while scanning single-quoted string<br>
  SyntaxError: invalid syntax</p>