472,334 Members | 1,531 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,334 software developers and data experts.

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 7508
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Joshua Forgione | last post by:
Hello. I am reverse engineering some Python Code. I am using the book "The Quick Python Book" as an aide. The following line exists in the...
1
by: Spark | last post by:
Hi folks, I embedded a javascript in HTML and tried to open the file using mozilla 1.4 it gave me the following exception in the script on...
1
by: kevininstructor | last post by:
The following was copied from a web site for learning formatting. Dim myInt As Integer = 100 Dim FormatPrice As String = String.Format("Price =...
6
by: Servé Lau | last post by:
suppose I want to use sscanf get the functionname from a function prototype. Is the following format string correct then? char funcname; char...
2
by: Kevin Walzer | last post by:
I'm getting an error in a Python script I'm writing: "not enough arguments for format string." The error comes at the end of the os.system command,...
3
by: stathisgotsis | last post by:
Hello everyone, Trusting K&R2 i thought until recently that spaces are ignored in scanf's format string. Reading arguments to the contrary...
10
by: tom | last post by:
Im trying understand format string vulnerability. Source along Erickson's HACKING: The Art of Exploitation. #include <stdlib.h> int main(int...
2
by: gregpinero | last post by:
I might just be being dumb tonight, but why doesn't this work: Traceback (most recent call last): File "<stdin>", line 1, in ? TypeError: not...
7
by: moondaddy | last post by:
I need to format a string to it always has 2 digits in it. I'm getting the month like this: DateTime.Now.Month.ToString() Right now since...
7
by: Andrus | last post by:
How to create format string for decimal data type which shows blank for zero and default format otherwize ? I tried format string "f;f;#" but...
0
by: concettolabs | last post by:
In today's business world, businesses are increasingly turning to PowerApps to develop custom business applications. PowerApps is a powerful tool...
0
better678
by: better678 | last post by:
Question: Discuss your understanding of the Java platform. Is the statement "Java is interpreted" correct? Answer: Java is an object-oriented...
0
by: Kemmylinns12 | last post by:
Blockchain technology has emerged as a transformative force in the business world, offering unprecedented opportunities for innovation and...
0
jalbright99669
by: jalbright99669 | last post by:
Am having a bit of a time with URL Rewrite. I need to incorporate http to https redirect with a reverse proxy. I have the URL Rewrite rules made...
0
by: antdb | last post by:
Ⅰ. Advantage of AntDB: hyper-convergence + streaming processing engine In the overall architecture, a new "hyper-convergence" concept was...
0
by: Matthew3360 | last post by:
Hi there. I have been struggling to find out how to use a variable as my location in my header redirect function. Here is my code. ...
0
by: AndyPSV | last post by:
HOW CAN I CREATE AN AI with an .executable file that would suck all files in the folder and on my computerHOW CAN I CREATE AN AI with an .executable...
0
by: Arjunsri | last post by:
I have a Redshift database that I need to use as an import data source. I have configured the DSN connection using the server, port, database, and...
0
hi
by: WisdomUfot | last post by:
It's an interesting question you've got about how Gmail hides the HTTP referrer when a link in an email is clicked. While I don't have the specific...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.