title: How to remove newlines and indents from a string in Python?
body: <p>In my Python script, I have a SQL statement that goes on forever like so:</p>
  
  <pre><code>query = """
      SELECT * FROM
          many_many
          tables
      WHERE
          this = that,
          a_bunch_of = other_conditions
  """
  </code></pre>
  
  <p>What's the best way to get this to read like a single line? I tried this:</p>
  
  <pre><code>def formattedQuery(query):
      lines = query.split('\n')
  
      for line in lines:
          line = line.lstrip()
          line = line.rstrip()
  
      return ' '.join(lines)
  </code></pre>
  
  <p>and it did remove newlines but not spaces from the indents. Please help!</p>