<div class="gmail_quote">On Wed, Nov 16, 2011 at 10:09 AM, Steven D&#39;Aprano <span dir="ltr">&lt;<a href="mailto:steve@pearwood.info">steve@pearwood.info</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">

<div class="im">Wayne Werner wrote:<br>&lt;snip&gt;</div><div class="im">
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
In old style formatting, you use a string with format specifiers (%s, %d,<br>
etc.) followed by a tuple of arguments. Here, the lengths have to match<br>
exactly - if you have one specifier then you must have a 1-element tuple.<br>
</blockquote>
<br></div>
That&#39;s actually wrong. If you have one specifier, you must have one object of any sort *except* a tuple.</blockquote><div><br></div><div>I think you misunderstood - I said a 1-element tuple - e.g. (3,)</div><div> </div>

<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;"><span style="background-color: transparent; "> </span></blockquote><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">


&gt;&gt;&gt; &quot;%s&quot; % 42  # One object not a tuple.<br>
&#39;42&#39;<br>
<br>
But if you have a tuple, the % formatting will try to use each element in the tuple separately:<br>
<br>
&gt;&gt;&gt; &quot;%s&quot; % (23, 42)  # One object which is a tuple<br></blockquote><div><br></div><div>As above, that&#39;s a two-element tuple. It was explained to me once that in this case:</div><div><br></div><div>

&quot;%s&quot; % 42</div><div><br></div><div>That since python expects to see a single-element tuple it treats it as or converts 42 to a single element tuple.</div><div><br></div><div>I suppose I could have called it a tuple of length 1 instead.</div>

<div><br></div><div>Sorry for the mistunderstanding,</div><div>Wayne</div></div>