title: Commas and strings in Python 2.7 string.format()
body: <p>I'm confused by the following Python 2.7 and Python 3.3 behavior in String formatting. This is a nitpicky detail question about how the comma operator interacts with string presentation types.</p>
  
  <pre><code>&gt;&gt;&gt; format(10000, ",d")
  '10,000'
  &gt;&gt;&gt; format(10000, ",")
  '10,000'
  &gt;&gt;&gt; format(10000, ",s")
  ValueError: Cannot specify ',' with 's'.
  
  &gt;&gt;&gt; "{:,}".format(10000)
  '10,000'
  &gt;&gt;&gt; "{:,s}".format(10000)
  ValueError: Cannot specify ',' with 's'.
  </code></pre>
  
  <p>What's confusing me is why the <code>,</code> variant works, the one with no explicit string presentation type. The <a href="http://docs.python.org/2/library/string.html#formatspec" rel="nofollow noreferrer">docs</a> say that if you omit the type, it's "The same as <code>s</code>." And yet here it is acting differently from <code>s</code>.</p>
  
  <p>I'd dismiss this as just a wrinkle / corner case, but this syntax is used as an example in the docs: <code>'{:,}'.format(1234567890)</code>. Are there other "special" behaviors hidden in Python when the string presentation type is omitted? Maybe instead of "same as s" what the code is really doing is inspecting the type of the thing being formatted?</p>