[Python-Dev] PEP 461: Adding % formatting to bytes and bytearray -- Final, Take 3
Ethan Furman
ethan at stoneleaf.us
Thu Mar 27 20:01:10 CET 2014
On 03/27/2014 11:53 AM, Guido van Rossum wrote:
>
> So what's the use case for Python 2/3 compatible code? IMO the main use case for the PEP is simply to be able to
> construct bytes from a combination of a template and some input that may include further bytes and numbers. E.g. in
> asyncio when you write an HTTP client or server you have to construct bytes to write to the socket, and I'd be happy if
> I could write b'HTTP/1.0 %d %b\r\n' % (status, message) rather than having to use str(status).encode('ascii') and
> concatenation or join().
My own dbf module [1] would make use of this feature, and I'm sure some of the pdf modules would as well (I recall
somebody chiming in about their own pdf module).
--
~Ethan~
[1] https://pypi.python.org/pypi/dbf
More information about the Python-Dev
mailing list