[Python-Dev] PEP 461: Adding % formatting to bytes and bytearray -- Final, Take 3 (original) (raw)
Gregory P. Smith greg at krypto.org
Sat Mar 29 20:01:53 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 Thu, Mar 27, 2014 at 3:47 AM, Victor Stinner <victor.stinner at gmail.com>wrote:
The PEP 461 looks good to me. It's a nice addition to Python 3.5 and the PEP is well defined.
+1
I can help to implement it. Maybe, it would be nice to provide an implementation as a third-party party module on PyPI for Python 2.6-3.4.
That is possible and would enable bytes formatting on earlier 3.x versions. I'm not sure if there is any value in backporting to 2.x as those already have such formatting with Python 2's str.mod % operator.
Though I don't know what it'd look like as an API as a module. Brainstorming: It'd either involve function calls to format instead of % or a container class to wrap format strings in with a mod method that calls the bytes formatting code instead of native str % formatting when needed.
From a 2.x-3.x compatible code standpoint the above could exist but the container class constructor would be a no-op on Python 2. if sys.version_info[0] == 2: BytesFormatter = str else: class BytesFormatter: ... def mod ...
-gps
Note: I fixed a typo in your PEP (reST syntax).
Victor 2014-03-26 23:47 GMT+01:00 Ethan Furman <ethan at stoneleaf.us>: >> This one is wrong: >> >>>>> repr(b'abc').encode('ascii', 'backslashreplace') >> >> b"b'abc'" > > > Fixed, thanks.
Python-Dev mailing list Python-Dev at python.org https://mail.python.org/mailman/listinfo/python-dev Unsubscribe: https://mail.python.org/mailman/options/python-dev/greg%40krypto.org -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://mail.python.org/pipermail/python-dev/attachments/20140329/603d2e38/attachment.html>
- 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 ]