[Python-Dev] PEP 461 - Adding % and {} formatting to bytes (original) (raw)
Nick Coghlan ncoghlan at gmail.com
Sat Jan 18 03:24:50 CET 2014
- Previous message: [Python-Dev] PEP 461 - Adding % and {} formatting to bytes
- Next message: [Python-Dev] PEP 461 - Adding % and {} formatting to bytes
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
On 18 Jan 2014 06:19, "Terry Reedy" <tjreedy at udel.edu> wrote:
On 1/17/2014 10:15 AM, Mark Lawrence wrote:
For both options 1 and 2 surely you cannot be suggesting that after people have written 2.x code to use format() as %f formatting is to be deprecated, I will not be for at least a decade.
It will not be deprecated, period. Originally, we thought that the introduction of the new flexible text formatting system made printf-style formatting redundant.
After running both in parallel for a while, we learned we were wrong:
- it's far more difficult than we originally anticipated to migrate away from it to the new text formatting system
- in particular, the lazy interpolation support in the logging module (and similar systems) has no reasonable migration path
- two different core interpolation systems make it much easier to interpolate into format strings
- it's a better fit for code which needs to semantically align with C
- it's a useful micro-optimisation
- as the current discussion shows, it's much better suited to the interpolation of ASCII compatible segments in binary data formats
Do many of the core devs strongly prefer the new formatting system? Yes. Were we originally planning to deprecate and remove the printf-style formatting system? Yes. Are there still any plans to do so? No. That's why we rewrote the relevant docs to always describe it as "mod formatting" or "printf-style formatting", rather than "legacy" or "old-style". If there are any instances (or even implications) of the latter left in the official docs, that's a bug to be fixed.
Perhaps this needs to be a new Q in my Python 3 Q&A, since a lot of people still seem to have the wrong idea...
Regards, Nick.
they now have to change the code back to the way they may well have written it in the first place? I would suggest that people simply .encode the result if bytes are needed in 3.x as well as 2.x. Polyglot code will likely have a 'py3' boolean already to make the encoding conditional. -- Terry Jan Reedy
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/ncoghlan%40gmail.com -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://mail.python.org/pipermail/python-dev/attachments/20140118/593ee089/attachment-0001.html>
- Previous message: [Python-Dev] PEP 461 - Adding % and {} formatting to bytes
- Next message: [Python-Dev] PEP 461 - Adding % and {} formatting to bytes
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]