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

Cameron Simpson cs at zip.com.au
Sun Feb 23 23:56:39 CET 2014

On 23Feb2014 22:56, Victor Stinner <victor.stinner at gmail.com> wrote:
> > An aid to debugging -- need to see what's what at that moment?  Toss it
> > into %a.  It is not intended for production code, but is included to
> > hopefully circumvent the inappropriate use of __bytes__ methods on classes.
> How do you plan to use this output? Write it into a socket or a file?
> When I debug, I use print & logging which both expect text string. So I
> think that b'%a' is useless.

The case from the email thread, which I support at +0.5 or maybe
only +0.1, is printing to a binary log. The classic example that
comes to mind is syslog packets.

I agree %a invites data mangling.

One would hope it doesn't see use in wire protocols, only in debugging
scenarios. Regrettably, syslog is such a binary logging protocol,
purportedly for "text".

Cameron Simpson <cs at zip.com.au>

We had the experience, but missed the meaning.  - T.S. Eliot

More information about the Python-Dev mailing list