<div dir="ltr"><br><div class="gmail_extra"><br><br><div class="gmail_quote">On Mon, Jan 13, 2014 at 4:51 PM, Guido van Rossum <span dir="ltr"><<a href="mailto:guido@python.org" target="_blank">guido@python.org</a>></span> wrote:<br>

<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Terminology. Let's use the official terminology rather than making stuff up.<br>
<br>
The docs at <a href="http://docs.python.org/3/library/string.html#formatspec" target="_blank">http://docs.python.org/3/library/string.html#formatspec</a><br>
use the following terminology:<br>
<br>
Replacement field: {...}; contains field name, conversion, format spec<br>
in that order, all optional.<br>
<br>
Field name: either a decimal integer (referring to an argument by<br>
position) or an identifier (by name), or omitted (uses the next<br>
available position).<br>
<br>
Conversion: !r, !s, !a; these refer to repr(), str(), ascii() to the<br>
value, and then the format spec applies to the resulting string.<br>
<br>
Format spec: colon, bunch of stuff, type; the type is a letter such as<br>
d (decimal) or s (string), and the stuff between the colon and the<br>
type is used to specify field width, alignment, sign, padding and<br>
such.<br>
<br>
<br>
Also. {:b} means binary (i.e. numbers in base 2). I'm not sure what<br>
this leaves for interpolating bytes if we don't want to use {:s}. The<br>
docs at <a href="http://docs.python.org/3/library/stdtypes.html#printf-style-string-formatting" target="_blank">http://docs.python.org/3/library/stdtypes.html#printf-style-string-formatting</a><br>
don't show %b so it could still be used there, but it would be nicer<br>
to be consistent.</blockquote><div><br></div><div>I have been going on the assumption that bytes.format() would change what '{}' meant for itself and would only interpolate bytes. That convenient between Python 2 and 3 since it represents what we want it to (str and bytes under the hood, respectively), so it just falls through. We could also add a 'b' conversion for bytes() explicitly so as to help people not accidentally mix up things in bytes.format() and str.format(). But I was not suggesting adding a specific format spec for bytes but instead making bytes.format() just do the .encode('ascii') automatically to help with compatibility when a format spec was present. If people want fancy formatting for bytes they can always do it themselves before calling bytes.format().</div>

</div></div></div>