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

Stephen J. Turnbull stephen at xemacs.org
Mon Feb 24 03:30:45 CET 2014

Glenn Linderman writes:
 > On 2/23/2014 2:25 PM, Antoine Pitrou wrote:
 >> On Sun, 23 Feb 2014 14:14:55 -0800 Glenn Linderman <v+python at g.nevcal.com> wrote:
 >>> On 2/23/2014 1:37 PM, Antoine Pitrou wrote:

 >>>> And you certainly*don't* print debugging output into a wire protocol.

 >>> Web server applications do, so they can be displayed in the browser.

 >> They may embed debugging information into some HTML code, which
 >> then will be sent over the wire.  However, usually they don't
 >> print debugging output directly into HTTP.

 > The HTML is sent over the wire via HTTP... that's pretty directly
 > in the wire protocol...

Not in the relevant sense.  In a modern web framework, the HTML will
typically be in internal text encoding because the framework can't
know what the programmer/web developer/user will be using.  So there's
no need at all for PEP 461 here: you're going to be using str, and
then running it through .encode() anyway.

 > the HTTP headers are immediately followed by the HTML, and when the
 > document is being generated on the fly, it may also be being
 > encoded on the fly. I've seen it done, although I can't confirm or
 > deny the "usually" claim you have made.

I'm sure you've seen it done.  Is it worth providing special support
for it?  I don't think so, and Nick's "we don't want people writing
__bytes__ methods" argument sounds suspiciously like a child-proof cap
to me.  If people really wanna do that, let them use ascii().

More information about the Python-Dev mailing list