How should I close a multi-line variable/comment in Python?
<p>I am receiving this error:</p>

<pre><code>  File "/DateDbLoop.py", line 33  
    d.Id""" % (str(day), str(2840))"  
    ^  
SyntaxError: EOL while scanning single-quoted string
</code></pre>

<p>Here is the script.  There are 4 double quotes to open this, but I am unsure how to correctly close this out?</p>

<p>Follow Up Question:</p>

<p>Does this % (str(day), str(2840)) need to go in both the sql variable and the os.system() call?</p>

<pre><code>#!/usr/bin/python

import datetime
import sys, os, time, string

a = datetime.date(2009, 1, 1)
b = datetime.date(2009, 2, 1)
one_day = datetime.timedelta(1)

day = a

while day &lt;= b:

    print "Running query for \"" + str(day) + "\""

    sql=""""SELECT
        d.Date,  
        SUM(d.Revenue),  
        FROM Table d  
        WHERE d.Date = '%s'  
        AND d.Id = %s  
        GROUP BY d.Date  
        """ % (str(day), str(2840))"

    os.system('mysql -h -sN -u  -p -e %s &gt; FileName-%s.txt db' % (sql, str(day)))
    day += one_day
</code></pre>
