[Python-Dev] PEP 461: Adding % formatting to bytes and bytearray -- Final, Take 3

Ethan Furman ethan at stoneleaf.us
Thu Mar 27 18:55:15 CET 2014


On 03/27/2014 10:29 AM, Guido van Rossum wrote:
>
> I also don't understand why we can't use %b instead of %s. AFAIK %b currently doesn't mean anything and I somehow don't
> expect we're likely to add it for other reasons (unless there's a proposal I'm missing?). Just like we use %a instead of
> %r to remind people that it's not quite the same (since it applies .encode('ascii', 'backslashreplace')), shouldn't we
> use anything *but* %s to remind people that that is also not the same (not at all, in fact)? The PEP's argument against
> %b ("rejected as not adding any value either in clarity or simplicity") is hardly a good reason.

The biggest reason to use %s is to support a common code base for 2/3 endeavors.  The biggest reason to not include %b 
is that it means binary number in format(); given that each type can invent it's own mini-language, this probably isn't 
a very strong argument against it.

I have moderate feelings for keeping %s as a synonym for %b for backwards compatibility with Py2 code (when it's 
appropriate).

--
~Ethan~


More information about the Python-Dev mailing list