[Python-Dev] Migration from Python 2.7 and bytes formatting (original) (raw)
Ryan Gonzalez rymg19 at gmail.com
Fri Jan 17 21:10:40 CET 2014
- Previous message: [Python-Dev] Migration from Python 2.7 and bytes formatting
- Next message: [Python-Dev] Migration from Python 2.7 and bytes formatting
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
A command line parameter??
The annoying part would be telling every single user to call Python with a certain argument and hope they read the README.
If it's a library, out of the question.
If it's a program, well, I hope your users read READMEs.
On Fri, Jan 17, 2014 at 4:49 AM, Neil Schemenauer <nas at arctrix.com> wrote:
As I see it, there are two separate goals in adding formatting methods to bytes. One is to make it easier to write new programs that manipulate byte data. Another is to make it easier to upgrade Python 2.x programs to Python 3.x. Here is an idea to better address these separate goals.
Introduce %-interpolation for bytes. Support the following format codes to aid in writing new code: %b: insert arbitrary bytes (via bytes or Pybuffer) %[dox]: insert an integer, encoded as ASCII %[eEfFgG]: insert a float, encoded as ASCII %a: call ascii(), insert result Add a command-line option, disabled by default, that enables the following format codes: %s: if the object has bytes or Pybuffer then insert it. Otherwise, call str() and encode with the 'ascii' codec %r: call repr(), encode with the 'ascii' codec %[iuX]: as per Python 2.x, for backwards compatibility Introducing these extra codes and the command-line option will provide a more gradual upgrade path. The next step in porting could be to examine each %s inside bytes literals and decide if they should either be converted to %b or if the literal should be converted to a unicode literal. Any %r codes could likely be safely changed to %a.
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/rymg19%40gmail.com
-- Ryan When your hammer is C++, everything begins to look like a thumb. -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://mail.python.org/pipermail/python-dev/attachments/20140117/6a251d21/attachment.html>
- Previous message: [Python-Dev] Migration from Python 2.7 and bytes formatting
- Next message: [Python-Dev] Migration from Python 2.7 and bytes formatting
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]