(original) (raw)


On 12 Jan 2014 22:10, "Paul Moore" <p.f.moore@gmail.com> wrote:
\>
\> On 12 January 2014 09:23, Georg Brandl <g.brandl@gmx.net> wrote:
\> >> On 12 January 2014 01:01, Victor Stinner <victor.stinner@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 :-)

It's also something asciistr will help with once it is working - asciistr(123) on the RHS will work in both versions.

Cheers,
Nick.

> Paul
\> \_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_
\> Python-Dev mailing list
\> Python-Dev@python.org
\> https://mail.python.org/mailman/listinfo/python-dev
\> Unsubscribe: https://mail.python.org/mailman/options/python-dev/ncoghlan%40gmail.com