[Python-Dev] PEP 460: allowing %d and %f and mojibake (original) (raw)
Paul Moore p.f.moore at gmail.com
Sun Jan 12 13:08:56 CET 2014
- Previous message: [Python-Dev] PEP 460: allowing %d and %f and mojibake
- Next message: [Python-Dev] PEP 460: allowing %d and %f and mojibake
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
On 12 January 2014 09:23, Georg Brandl <g.brandl at gmx.net> wrote:
On 12 January 2014 01:01, Victor Stinner <victor.stinner at gmail.com> wrote:
Supporting formating integers would allow to write b"Content-Length: %s\r\n" % 123, which would work on Python 2 and Python 3.
I'm surprised that no-one is mentioning b"Content-Length: %s\r\n" % str(123) which works on Python 2 and 3, is explicit, and needs no special-casing of int in the format code. Certainly doesn't work on Python 3 right now, and never should :)
Sorry, I meant str(123).encode("ascii"), and I'd probably use a helper function for it.
I could easily argue at this point that this is the type of bug that having %-formatting operations on bytes would encourage - %s means "format a string" (from years of C and Python (text) experience) so I automatically supply a string argument when using %s in a bytes formatting context.
The reality is that I was probably just being sloppy, though :-) Paul
- Previous message: [Python-Dev] PEP 460: allowing %d and %f and mojibake
- Next message: [Python-Dev] PEP 460: allowing %d and %f and mojibake
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]