[Python-Dev] PEP 461: Adding % formatting to bytes and bytearray -- Final, Take 3 (original) (raw)
Nick Coghlan ncoghlan at gmail.com
Thu Mar 27 12:42:14 CET 2014
- Previous message: [Python-Dev] PEP 461: Adding % formatting to bytes and bytearray -- Final, Take 3
- Next message: [Python-Dev] PEP 461: Adding % formatting to bytes and bytearray -- Final, Take 3
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
On 27 March 2014 21:24, Antoine Pitrou <solipsis at pitrou.net> wrote:
On Tue, 25 Mar 2014 15:37:11 -0700 Ethan Furman <ethan at stoneleaf.us> wrote:
%a
will callascii()
on the interpolated value. This is intended as a debugging aid, rather than something that should be used in production. Non-ASCII values will be encoded to either\xnn
or\unnnn
representation. Use cases include developing a new protocol and writing landmarks into the stream; debugging data going into an existing protocol to see if the problem is the protocol itself or bad data; a fall-back for a serialization format; or even a rudimentary serialization format when defining_bytes_
would not be appropriate [8]. The "use cases" you are enumerating for "%a" are chimeric. Did you actually do those things in real life, or are you inventing them for the PEP?
I'm the one that raised the "discourage misuse of bytes" concern, so I'd like %a to stay in at least for that reason. %a is a perfectly well defined format code (albeit one you'd only be likely to use while messing about with serialisation protocols, as the PEP describes - for example, if a %b code was ending up producing wrong data, you might switch to %a temporarily to get a better idea of where the bad data was coming from), while using bytes to make %s behave the way %a is defined in the PEP would just be wrong in most cases. I consider %a the preemptive PEP 308 of binary interpolation format codes - in the absence of %a, I'm certain that users would end up abusing bytes and %s to get the same effect, just as they used the known bug magnet that was the and/or hack for a long time in the absence of PEP 308.
I also seem to recall Guido saying he liked it, which flipped the discussion from "do we have a good rationale for including it?" to "do we have a good rationale for the BDFL to ignore his instincts?". However, it would be up to Guido to confirm that recollection, and if "Guido likes it" is part of the reason for inclusion of the %a code, the PEP should mention that explicitly.
Cheers, Nick.
-- Nick Coghlan | ncoghlan at gmail.com | Brisbane, Australia
- Previous message: [Python-Dev] PEP 461: Adding % formatting to bytes and bytearray -- Final, Take 3
- Next message: [Python-Dev] PEP 461: Adding % formatting to bytes and bytearray -- Final, Take 3
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]