[Python-Dev] RFC: PEP 460: Add bytes % args and bytes.format(args) to Python 3.5 (original) (raw)
INADA Naoki songofacandy at gmail.com
Sat Jan 11 04:30:23 CET 2014
- Previous message: [Python-Dev] RFC: PEP 460: Add bytes % args and bytes.format(args) to Python 3.5
- Next message: [Python-Dev] RFC: PEP 460: Add bytes % args and bytes.format(args) to Python 3.5
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
To avoid implicit conversion between str and bytes, I propose adding only limited %-format, not .format() or .format_map().
"limited %-format" means:
%c accepts integer or bytes having one length. %r is not supported %s accepts only bytes. %a is only format accepts arbitrary object.
And other formats is same to str.
On Sat, Jan 11, 2014 at 8:24 AM, Antoine Pitrou <solipsis at pitrou.net> wrote:
On Fri, 10 Jan 2014 18:14:45 -0500 "Eric V. Smith" <eric at trueblade.com> wrote: > > >> Because embedding the ASCII equivalent of ints and floats in byte streams > >> is a common operation? > > > > Again, if you're representing "ASCII", you're representing text and > > should use a str object. > > Yes, but is there existing 2.x code that uses %s for int and float > (perhaps unwittingly), and do we want to "help" that code out? > Or do we > want to make porters first change to using %d or %f instead of %s?
I'm afraid you're misunderstanding me. The PEP doesn't allow for %d and %f on bytes objects. > I think what you're getting at is that in addition to not calling > format, we don't want to call str, either, for the same reason. Not only. We don't want to do anything that actually asks for a textual representation of something. %d and %f ask for a textual representation of a number, so they're right out. Regards Antoine.
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/songofacandy%40gmail.com
-- INADA Naoki <songofacandy at gmail.com> -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://mail.python.org/pipermail/python-dev/attachments/20140111/c1677de9/attachment.html>
- Previous message: [Python-Dev] RFC: PEP 460: Add bytes % args and bytes.format(args) to Python 3.5
- Next message: [Python-Dev] RFC: PEP 460: Add bytes % args and bytes.format(args) to Python 3.5
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]