Not enough arguments for format string

Paul McGuire ptmcg at austin.rr._bogus_.com
Sun Nov 19 22:05:51 EST 2006


"ronrsr" <ronrsr at gmail.com> wrote in message 
news:1163991320.262638.154950 at j44g2000cwa.googlegroups.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 





More information about the Python-list mailing list