[Python-Dev] PEP 460: allowing %d and %f and mojibake

Paul Moore p.f.moore at gmail.com
Sun Jan 12 18:04:20 CET 2014

On 12 January 2014 16:52, Kristján Valur Jónsson <kristjan at ccpgames.com> wrote:
> I mean, basically what I am suggesting is that in addition to %b with
> def helper(o):
>     return str(o).encode('ascii', 'strict')
> b'foo%bbar'%(helper(myobj), )
> you have
> b'foo%sbar'%(myobj, )

But that's not what the current PEP says. It uses %s for interpolating
bytes values. It looks like you're saying that

b'abc %s' % (b'def')

will *not* produce b'abc def', but rather will produce b'abc b\'def\''
(because str(b'def'') is "b'def'").

If that's what you're saying, then fine, but it's a different PEP and
I for one am -1 specifically because of the behaviour I show above.

More information about the Python-Dev mailing list