469,282 Members | 2,034 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,282 developers. It's quick & easy.

Not enough arguments for format string

is the error message I'm getting here, on the long formatted print
statement. . I've tried adding arguments, in case I missed one, and it
still gets a syntax error.

here's the info:

#row is a dictionary with keys: zid, keywords, citation, quotation
def print_row(row):
print row;
print "row in
print_row","kw=",row["keywords"],"q=",row["quotation"],"c =
",row["citation"],"xyzzy row"
print """<tr>
<td class="pad">%s
</td>
<td class="pad">%s
</td>
<td class="pad">%s
</td>
<td class="pad" align="center"><form action="update.cgi"
name="updateform" enctype="application/x-www-form-urlencoded"
method="GET"><input type="hidden" name="zid" value="%d"><input
type="submit" value="Edit"></form>
</td>
</tr>
"""%row['keywords'],row['quotation'],row['citation'],row['zid']
print "done printrow xyzzy"


here's the output, with my debugging info:

{'keywords': 'Agricultural Subsidies, Farmers', 'zid': 319L,
'citation': '\xe2\x80\x9cAgriculture in Crisis,\xe2\x80\x9d
<i>Rethinking US Agricultural Policy: Changing Course to Secure Farmer
Livelihoods Worldwide</i>, September 2003, 9', 'quotation': 'In 2001,
government payments to farmers amounted to an astounding 47 percent of
farmer income, up from about 20 percent in the 1990s. Despite this
enormous infusion of cash, farmer income declined steadily during the
same period, and many US farmers are under increasing financial
stress.'}
row in print_row kw= Agricultural Subsidies, Farmers q= In 2001,
government payments to farmers amounted to an astounding 47 percent of
farmer income, up from about 20 percent in the 1990s. Despite this
enormous infusion of cash, farmer income declined steadily during the
same period, and many US farmers are under increasing financial stress.
c = "Agriculture in Crisis," <i>Rethinking US Agricultural Policy:
Changing Course to Secure Farmer Livelihoods Worldwide</i>, September
2003, 9 xyzzy row
Traceback (most recent call last):
File "C:\Documents and Settings\Ronald\My
Documents\spi\zingers\public_html\display.py", line 116, in ?
zhtml.print_row(adict)
File "C:\Documents and Settings\Ronald\My
Documents\spi\zingers\public_html\zhtml.py", line 222, in print_row
print """<tr>
TypeError: not enough arguments for format string
thanks once again,

-rsr-

Nov 20 '06 #1
3 7150
Change:

"""%row['keywords'],row['quotation'],row['citation'],row['zid']

to

""" % (row['keywords'],row['quotation'],row['citation'],row['zid'])

-- Paul
Nov 20 '06 #2
"ronrsr" <ro****@gmail.comwrote in message
news:11**********************@j44g2000cwa.googlegr oups.com...
is the error message I'm getting here, on the long formatted print
statement. . I've tried adding arguments, in case I missed one, and it

print """<tr>
<td class="pad">%s
</td>
<td class="pad">%s
</td>
<td class="pad">%s
</td>
<td class="pad" align="center"><form action="update.cgi"
name="updateform" enctype="application/x-www-form-urlencoded"
method="GET"><input type="hidden" name="zid" value="%d"><input
type="submit" value="Edit"></form>
</td>
</tr>
"""%row['keywords'],row['quotation'],row['citation'],row['zid']
print "done printrow xyzzy"
Another technique is to use named string fields in the interpolation format:

print """<tr>
<td class="pad">%(keywords)s
</td>
<td class="pad">%(quotation)s
</td>
<td class="pad">%(citation)s
</td>
<td class="pad" align="center"><form action="update.cgi"
name="updateform" enctype="application/x-www-form-urlencoded"
method="GET"><input type="hidden" name="zid" value="%(zid)d"><input
type="submit" value="Edit"></form>
</td>
</tr>
""" % row

This style is a bit easier to follow, and later maintain.

-- Paul
Nov 20 '06 #3
thanks. solution 1 worked like a charm.
Paul McGuire wrote:
"ronrsr" <ro****@gmail.comwrote in message
news:11**********************@j44g2000cwa.googlegr oups.com...
is the error message I'm getting here, on the long formatted print
Nov 20 '06 #4

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

2 posts views Thread by Joshua Forgione | last post: by
1 post views Thread by Spark | last post: by
1 post views Thread by kevininstructor | last post: by
6 posts views Thread by Servé Lau | last post: by
2 posts views Thread by Kevin Walzer | last post: by
3 posts views Thread by stathisgotsis | last post: by
10 posts views Thread by tom | last post: by
2 posts views Thread by gregpinero | last post: by
7 posts views Thread by moondaddy | last post: by
reply views Thread by zhoujie | last post: by
reply views Thread by suresh191 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.