On 13/01/14 03:47, Guido van Rossum wrote:
On Sun, Jan 12, 2014 at 6:24 PM, Ethan Furman <et...@stoneleaf.us> wrote:
On 01/12/2014 06:16 PM, Ethan Furman wrote:
If you do :
--> b'%s' % 'some text'
Ignore what I previously said. With no encoding the result would be:
b"'some text'"
So an encoding should definitely be specified.
Yes, but the encoding is no business of %s or %. As far as the
formatting operation cares, if the argument is bytes they will be
copied literally, and if the argument is a str (or anything else) it
will call ascii() on it.
It seems to me that what people want from '%s' is:
Convert to a str then encode as ascii for non-bytes
or copy directly for bytes.
So why not replace '%s' with '%a' for the ascii case and
with '%b' for directly inserting bytes.
That way, the encoding is explicit.
I think it is vital that the encoding is explicit in all cases where
bytes <-> str conversion occurs.
Cheers,
Mark.
_______________________________________________
Python-Dev mailing list
Python-Dev@python.org
https://mail.python.org/mailman/listinfo/python-dev
Unsubscribe:
https://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com