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.
>>> format(10000, ",d")
'10,000'
>>> format(10000, ",")
'10,000'
>>> format(10000, ",s")
ValueError: Cannot specify ',' with 's'.
>>> "{:,}".format(10000)
'10,000'
>>> "{:,s}".format(10000)
ValueError: Cannot specify ',' with 's'.
What's confusing me is why the , variant works, the one with no explicit string presentation type. The docs say that if you omit the type, it's "The same as s." And yet here it is acting differently from s.
I'd dismiss this as just a wrinkle / corner case, but this syntax is used as an example in the docs: '{:,}'.format(1234567890). 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?