[Python-Dev] PEP 461: Adding % formatting to bytes and bytearray -- Final, Take 3 (original) (raw)
Ethan Furman ethan at stoneleaf.us
Thu Mar 27 20:01:10 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 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
- 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 ]